bcp statement written on multiple lines

  • This works:

    exec master..xp_cmdshell

    'bcp "SELECT * FROM CsvData..UserStats" queryout c:\test.csv  /t "\",""  -c'

    If I try to put the statement on multiple lines, it does not work (tried + signs and &amp

    exec master..xp_cmdshell

    'bcp "SELECT * FROM CsvData..UserStats"

    queryout c:\test.csv

    /t "\",""  -c'

  • It looks like xp_cmdshell only uses the first line as the command to run.

    I tried running a command using ^ (needed in the command prompt to split a command over multiple lines) and I still got nothing.

    It does work if you concatenate it as one line in a local variable first, then call xp_cmdshell with the local variable.

Viewing 2 posts - 1 through 1 (of 1 total)

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