I want to use single quotes inside a transact sql statement, and then execute that statement.
for example my query:
Select * FROM MyTable WHERE MyTable.Id = '1'
now i want to use like this:
Declare @SQLQuery AS NVarchar(4000) SET @SQLQuery = ' Select * FROM MyTable WHERE MyTable.Id = '1' ' Execute (@SQLQuery)
this does not work and this error occurred:
Invalid column name '1'
I know that the problem is the quotes in the left and right parts 1
this is a sample and I want to use this method for a large request
of course i want to use a local variable instead, like '1', and my local variable is varchar
any idea?
sql tsql sql-server-2008
hamed aj
source share