[ACCEPTED]-Using bcp utility to export SQL queries to a text file-bcp
Accepted answer
bcp out
exports tables.
To export a query use queryout
instead 2 - you'll need to wrap your query in "double 1 quotes"
set @logtext = '"select name, type from master.dbo.spt_values where number=6"'
--set @logtext = 'master.dbo.spt_values'
SET @cmd = 'bcp ' + @logtext + ' queryout "c:\spt_values.dat" -U uId -P uPass -c'
EXEC master..XP_CMDSHELL @cmd
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.