SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Spool to a text file?
 New Topic  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

22828 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

52325 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  
 New 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.05 seconds. Powered By: Snitz Forums 2000