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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Query Analyzer Results to a file - Possible?

Status
Not open for further replies.

CTekGirl

MIS
Jul 23, 2003
76
US
I read in WINNET magazine that it is not possible to send the query results to an output file. This was in version 7 of SQL Server. Does anyone know if this is correct or if this is still the case with SQL Server 2000? I tried a couple of different spool commands, but it did not work. The only suggestion it gave was to do a select all,copy and paste into a text file. Isn't there some way to incorporate this into the SQL code. Any examples would be appreciated.
 
If you are running a command via osql or isql they you can feed the output to a file with the -o flag. If you mean in a stored procedure by it self, then no. You would need to use DTS to get the output of the query to a text file.

If you just need to get your output from QA to a text file then yes you can. If in grid view, select all, right click, save as. If you have not run the query yet, hit <CTRL><SHIFT>F and it will prompt you to save to a file.

Denny

--Anything is possible. All it takes is a little research. (Me)
 
Do you have a syntax example using this -o flag. thx
 
osql -S ServerName -d master -Q "select * from sysobjects" -o "c:\output.txt" -E -n

Denny

--Anything is possible. All it takes is a little research. (Me)
 
In regards to Q "select * from sysobjects"
Can I put the name of the query in the quotes, or is this an actual SQL statement? thx in advance
 
You put in any valid SQL statement. If you want to run a stored procedure, then put that in here. There are more flags available. Run osql /? from a command prompt to see them.

Denny

--Anything is possible. All it takes is a little research. (Me)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top