Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Table Output to txt file

Status
Not open for further replies.

Jimmy2128

Programmer
Feb 6, 2003
58
US
I have a table with customers information that updates updates twice a day (SQL Job) for our shipping software. I need to be able to export the table as .txt file to imported into the shipping software. Can you please tell me how can I create an output store precedure...

Thanks\

Jimmy
 
You would have to execute BCP within your stored procedure to accomplish this. Something like ...

Code:
EXEC Master..xp_CmdShell 

'BCP "SELECT * FROM CustomerTable" queryout customers.txt -n -t, -S MyServer -U MyUser -P MyPass'
You will need to fill in the MyServer with your servername, MyUser and MyPass with the appropriate security credentials.

You could also look into using DTS. With DTS you have much more flexibility, control and an added feature of being able to email alerts or progress reports via email if you set up an email account to be leveraged by DTS and SQL Server.

Thanks

J. Kusch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top