May 17, 2006 at 2:41 am
Hi
Could someone please help. I am trying to output results to a file (report). I've tried the code below but get the the wrong output:
Thanks in advance.
Code:
exec master..xp_cmdshell
'bcp "SELECT au_fname, au_lname
FROM pubs..authors
ORDER BY au_lname"
queryout "c:\SQL_Test.txt" -c -Sdcmjhbdev15'
Result:
output
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-V file format version] [-q quoted identifier]
[-C code page specifier] [-t field terminator] [-r row terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"]
(12 row(s) affected)
May 17, 2006 at 9:42 am
Your BCP syntax is fine. You are seeing a problem with how xp_cmdshell is interpreting the double quotes. Try using set quoted_identifier on before your exec statement.
May 18, 2006 at 6:07 am
Thanks. That fixed the problem.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply