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
" Erro开发者_运维技巧r: Conflicting switches : -U and -E "
Any help really appreciated
Start -> Run... -> cmd
And try to execute this command without -o key and its value :) I think problem is with command parameters.
And what is the parameter "-localhost". Beybe you forgot about S key? And what is the -C parameter key?
Try this:
DECLARE @cmd VARCHAR(2048)
SET @cmd = 'OSQL -Slocalhost '
+ ' -UCRN370 -PCRN370'
+ ' -Q"SELECT TOP 5 GageId FROM EwQMS370..msgages"'
+ ' -oc:\authors.txt'
EXEC master..xp_cmdshell @cmd, NO_OUTPUT
精彩评论