Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 I want to create a file with the results

Author  Topic 

marimarthe
Starting Member

1 Post

Posted - 2005-08-23 : 05:48:27
I want to do a SQL sentence that saves the results from the select in a .txt file.
I get the results as a long list on the screen, and it repeats the headers several times, so it takes quite some time to copy the results out of there. It would be better if the result was put as a list directly in to a text file.

Anyone know how I can do that?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-23 : 06:08:22
Try this

Exec master..xp_cmdShell 'bcp "Select columns from DBname..TableName"
queryout "C:\test.txt" -c'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -