Unable to execute this TSQL code

  • exec master..xp_cmdshell 'bcp "SELECT au_fname, au_lname FROM pubs..authors

    ORDER BY au_lname" queryout c:\file.txt -T -SBLRKEC24506\INFY -c'

    when I execute the above code i come across the belwo output, please help me get the desired output. Also please let me know if theres any way to get the results of a system stored procedure into a text file.

    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"] [-x generate xml format file]

    NULL

    Thanks,

    Sid

  • Hi,

    Write whole command in single line, remove line break(s) from the parameter of xp_cmpshell procedure

    Best Regards

    Nitin

    http://www.enlinkURL.com

    Regards,
    Nitin

  • exec master..xp_cmdshell 'bcp "SELECT au_fname, au_lname FROM pubs..authors ORDER BY au_lname" queryout c:\file.txt -T -S[BLRKEC24506\INFY] -c'


    N 56°04'39.16"
    E 12°55'05.25"

  • thanks all...

    it worked

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply