Skip to content
Advertisement

how to use single quotations inside a transact sql statement

i want use single quotations inside a transact sql statement, then execute that statement.

for example my query is:

now i want use like this:

this not work, and this error occurred :

Invalid column name ‘1’

I know problem is quotations in left and right side of the 1

this is a sample and i want use of this way to a large query

of course, i want use local variable instead for example ‘1’ and my local variable is varchar

any idea?

Advertisement

Answer

Just escape the quotes:

change

to

** Edit **

To include a local variable in the result, you could updated your query like this:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement