BCP is not working in when i am executing using xp_cmdshell

Declare @cmd varchar(300)
Set @cmd=
'bcp "SELECT definition + char(13) + ''GO'' FROM test.sys.sql_modules s INNER JOIN test.sys.procedures p ON [s].[object_id] = [p].[object_id] 
 WHERE p.name LIKE ''create%''" queryout "V:\SQLBackups\SP_scripts.sql" -C -T -t -w'
 exec xp_cmdshell @cmd
below is the result i am getting its not creating any sql script its working perfectly from cmd prompt
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]
  [-d database name]        [-K application intent]
NULL
any help is highly appreciated 
Thanks
AK

issue got resolved sql command should be in single line :)

Similar Messages

Maybe you are looking for