Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force SELECT to file.

Status
Not open for further replies.

grnzbra

Programmer
Mar 12, 2002
1,273
US
I can write a SELECT statement in Query Analyzer and then click on an icon and have the output go to a file. Is there any way to include in the SELECT statement something to tell SQL Server that I want the output to go to the file?
 
Sounds like s job for PowerShell, or an SSIS package, or bcp. It's not a feature of native T-SQL. SSMS has the capability to direct output to a file, and even include the query text, but it's not scriptable AFAIK.

-----------
With business clients like mine, you'd be better off herding cats.
 
Thank you for the clarification. I'll check into SSIS and bcp.
 
Is this a script that is always run the same way? If so, you could put it into a job and have the job output the results where you want.

-SQLBill


The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
sqlcmd -U<user> -P<password> -S<server> -d<database> -I<sql query from input file> -o<output file>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top