April 22, 2009 at 6:01 am
Hi, We are executing sql commands/scripts thru sql query analyzer. We want to capture the query execution output to a file using sql command in the script and not by selecting on result to file option. Is there a way to achieve this ?
April 22, 2009 at 6:13 am
Hope this helps
http://forums.sqlwire.com/showthread.php?t=20063
http://www.bigresource.com/MS_SQL-Query-results-to-text-file--sxhmazqA.html#
"Don't limit your challenges, challenge your limits"
April 22, 2009 at 6:15 am
you cannot do that;
While some programs, like SQLPlus for Oracle, interpret certain commands to change the connection or to direct the input to a file, SSMS and Query Analyzer only accept the commands thru the user interface...not thru the code it is executing.
I believe you can use osql to do that though...osql can be run from a command line, and any output cna use the standard DOS commands to send to a file, right?
Lowell
April 22, 2009 at 6:19 am
you can use BCP too.
"Don't limit your challenges, challenge your limits"
April 22, 2009 at 7:43 am
Using sqlcmd would be the 2005ie way to do it. Same for 2008.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 22, 2009 at 11:46 pm
Hi,
I hv tried sqlcmd and it seems to be more sophisticated way to do it.
However wish it could be achieved thru query analyzer too some day.
Thanks for your prompt inputs.:-)
April 23, 2009 at 5:52 am
The thing is, the query window in SSMS is for manual entry, not automation. It's unlikely they'll automate it when MS is already providing sqlcmd.exe and PowerShell scripts (another option). If you need automation, go to those utilities. When you're running stuff manually, go to the query window.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply