Q
Problem solve Get help with specific problems with your technologies, process and projects.

Load a text file in a table and then remove text file from directory

I want to load a text file in a table and then remove the text file from the directory. How can I do that in SQL Server?

Thank you,
Didier NEAU

You use xp_cmdshell and BCP to do this. The basics are as follows:

exec master..xp_cmdshell 'bcp pubs..authors in c:filesauthors.txt /c /T' exec master..xp_cmdshell 'del c:filesauthors.txt'

 

For More Information

Dig Deeper on Microsoft SQL Server Installation

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchBusinessAnalytics

SearchDataCenter

SearchDataManagement

SearchAWS

SearchOracle

SearchContentManagement

SearchWindowsServer

Close