bcp

  • declare

    @sql varchar(8000)

    select

    @sql = 'bcp ORLANDO..(select * from vwEmpReport) out

    c:\bcp\report.csv -c -t, -T -S'

    + @@servername

    exec

    master..xp_cmdshell @sql

     

    when i run this query csv file is not created. why?

  • Print the value of @sql, and run it from the command line, and you should have your answer.

  • TRY changing @sql to

    select @sql = 'bcp "select * from ORLANDO..vwEmpReport" queryout

    c:\bcp\report.csv -c -t, -T -S'+ @@servername


    * Noel

  • I get this as 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"]

    NULL

     

    with message

    (12 row(s) affected)

    but i dont see any file in my folder

  • Um, try space after -S in -S' +@@ ie:

    select @sql = 'bcp "select * from ORLANDO..vwEmpReport" queryout

    c:\bcp\report.csv -c -t, -T -S'+ @@servername

    CHANGES TO:

    select @sql = 'bcp "select * from ORLANDO..vwEmpReport" queryout

    c:\bcp\report.csv -c -t, -T -S '+ @@servername

    So long, and thanks for all the fishpaste 😉

  • select @sql = 'bcp ORLANDO..vwEmpReport out

    c:\bcp\report.csv -c -t, -T -S'+ @@servername

    _____________
    Code for TallyGenerator

Viewing 6 posts - 1 through 5 (of 5 total)

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