June 9, 2005 at 7:24 am
Hi All,
I'm interested, if there is a command I could place in the beginning of a T-SQL script to save its results to file - instead of choosing in QA menu Query -> Results to File? (By analogy with setting database either from toolbar or by placing 'use [database_name]' command)
Thanks
Anna Pimenova
June 9, 2005 at 7:45 am
Yep, that's already a feature of QA.
Just click on the drop down box next to the execution mode (where you say whether the results should be in text or a grid), the bottom option is to file.
Hope this helps
June 9, 2005 at 7:53 am
Sorry, I asked about the command (text) to type in the script that would do the same as choosing the option from the menu or drop down box.
I'd like to make it easier to a person who will execute the script - so that he/she will not have to set any options by him/herself
June 10, 2005 at 6:42 am
you can use master..xpcmdshell with bcp.exe. something like this
for syntax pls refer to help on xp_cmdshell and bcp
This may help you
June 10, 2005 at 7:42 am
Hi,
For this you can check the link http://spaces.msn.com/members/sudheerpalyam/Blog/cns!1pKCMhBsSwPMevqFfdi-3JgQ!166.entry
June 10, 2005 at 8:10 am
you can execute the query like this in QA. The output will be stored in the c:\file.txt
DECLARE @cmd varchar(130)
SET @cmd = 'bcp ' + '"' + 'select * from pubs..titles' + '"' + ' queryout c:\file.txt -U sa -P -c'
exec master..xp_cmdshell @cmd , NO_OUTPUT
June 10, 2005 at 1:32 pm
Would any user be able to use the preceeding method in QA? Or would they need permissions beyond SELECT to exec xp_cmdshell ?
Thx.
June 10, 2005 at 1:42 pm
OSQL?
June 12, 2005 at 1:33 pm
It depends on whether the dba had set it so only sysadmin role members could use it.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply