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
 Saving results to a text file

Author  Topic 

AClb55
Starting Member

3 Posts

Posted - 2011-07-20 : 14:52:23
In SSMS 2008, I am running a query and I need the results to be a tab delimited text file. I have figured this step out already, but I am wondering if there is a way to get there results automatically saved into a text file. I have done searches but I can not find a detailed description of how to do this and how it works. Thanks.

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-07-20 : 14:56:02
The bcp command line utility is perfect for this kind of thing: http://msdn.microsoft.com/en-us/library/ms162802.aspx

You can also use sqlcmd to create an output file, you have to tweak it to use tabs though: http://msdn.microsoft.com/en-us/library/ms162773.aspx
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-07-20 : 14:57:04
I prefer to use bcp, which is a command-line utility that allows you to import and export data. You can also choose to use SSIS, OPENROWSET, or even the import/export wizard.

After reviewing what these offer, let us know which one you want and we can get you some more detail.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-07-20 : 14:57:32
by a whole minute!

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-07-20 : 15:01:11
Blame the kids.

Or the job, whichever is most distracting.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-07-20 : 15:02:17
Or my lunch, lol. I typically work through the lunch and was busy chomping away while I replied.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -