tags:

views:

149

answers:

1

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

+1  A: 
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
silent
Thanks for your reply. Now its Works perfectly. "localhost" is my server name
mahesh kumar
So please accept my answer :)
silent