SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
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  

charliebrown
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!

madhivanan
Premature Yak Congratulator

India
22713 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

Madhivanan

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

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

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

1. bcp
2. OPENROWSET
3. SSIS export import

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


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

charliebrown
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.06 seconds. Powered By: Snitz Forums 2000