I have a problem where I need to store the select statement as a value in a field in database for the web service to execute it later and show the result in a different application.
When I update the value with the select statement in the table escaping the single quotes I loose the unicode N
prefix functionality.
Example:
update table
set sqlstatement = 'select No as N''Ī'' from table'
where ID = 1
When executing the saved SQL statement, the column name is returned as 'I' not 'Ī'
Is there any special way to escape single quotes when using N
prefix?
Add N to the head of 'select No as N''Ī'' from table'
declare @table as table(id int identity(1,1),sqlstatement nvarchar(100))
insert into @table values('select No as N''Ī'' from table')
--before
select sqlstatement from @table where Id=1
declare @sqlstatement as nvarchar(100)
update @table
set sqlstatement = N'select No as N''Ī'' from table'
where ID = 1
--After
select sqlstatement from @table where Id=1