-3

I have a set statement. I am trying to add a where statement inside that. However, when I put a single quote, it is not executing. How to escape the single quote in where clause to execute the set statement? Below is my code:

DECLARE @desttablename NVARCHAR(MAX)
SET @desttablename = 'select distinct desttablename 
from #table_norm 
where desttablename = 'Screener''
Sriram NR
  • 41
  • 5

1 Answers1

0

I found an alternative way to do this:

select @desttablename = (select distinct desttablename from #table_norm where 
desttablename = 'Screener')
Sriram NR
  • 41
  • 5