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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Spool to a text file?
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

4 Posts

Posted - 02/08/2013 :  08:18:55  Show Profile  Reply with Quote
Hello, I am a real noob at SQL programming and was wondering if someone could tell me how it would be possible for me to have my sql script output to a txt file?

For example the sql script file I have saved is select * from abc.def:

1. How can I automate the output to a txt file?
2. How can I run the script from a command line since I am doing this now from SSMS.

Thank you!

Premature Yak Congratulator

22864 Posts

Posted - 02/08/2013 :  08:20:18  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Read about BCP in SQL Server help file


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

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 02/08/2013 :  09:07:07  Show Profile  Reply with Quote
you've multiple options

1. bcp
3. SSIS export import

1 and 3 (using dtexec) can be executed from command line

SQL Server MVP

Go to Top of Page

Starting Member

4 Posts

Posted - 02/08/2013 :  09:13:06  Show Profile  Reply with Quote
I took a look at bcp and wow that looks pretty hard.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000