Save Sql Recordset into the Flat text file?

Posted by mahesh kumar on Stack Overflow See other posts from Stack Overflow or by mahesh kumar
Published on 2009-11-09T10:59:10Z Indexed on 2010/03/24 14:03 UTC
Read the original article Hit count: 226

Filed under:
|

Hi,

i need to dump my sql query result into the text file. i have created the following query,

DECLARE @cmd VARCHAR(2048) 

SET @cmd = 'OSQL -localhost -CRN370 ' 
+ ' -UCRN370 -PCRN370' 
+ ' -Q"SELECT TOP 5 GageId FROM EwQMS370..msgages"' 
+ ' -oc:\authors.txt' 
EXEC master..xp_cmdshell @cmd, NO_OUTPUT

The above query created the text file authors.txt. But the content of the file shows the following error message

" Error: Conflicting switches : -U and -E "

Any help really appreciated

© Stack Overflow or respective owner

Related posts about sql

Related posts about bcp