I am trying to add a parameter to a bcp query that will be run in xp_cmdshell but am getting a syntax error at the '+' character. Been staring at it for two hours and have concluded that some outside help is needed.
The command is:
EXEC xp_cmdshell 'bcp "SELECT * FROM [CensusData].[dbo].[Main] where zBarCode = ' + @zBarCode + '" queryout "C:\temp_housing_data.txt" -T -c -t -S "MyServerName"'
The syntax is on the first '+' character and it simply says "Incorrect syntax near '+'"
View Complete Post