Вопрос

I am trying to run the following command from SSMS:

EXEC xp_cmdshell 'bcp "SELECT *  FROM [erpSQL].[dbo].[Documents]  WHERE NoDoc like 'F%' and DateDoc = cast(GETDATE() as DATE)" queryout "d:\test.txt" -c -t -T ' 

and of course I have an error with like 'F%', saying Incorrect syntax near 'F'.
How do I handle that ?
I tried doubling the single quotes, but it's not that.
I tried using doubles quotes instead, that gives me an error near AND.

Thanks !

Это было полезно?

Решение 2

You need to escape the 'F%' paramenter. You can do this by adding anoter ' at the begining and the end of your current parameter, like this ''F%''.

Другие советы

Retry to use the escape sequence for single quote:

WHERE NoDoc like ''F%''

It must work!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top