Hi, I am using sql below to update a table with variable values in insert sql. records are inserted without singlequotes ('). How can I make it work?
declare @config_id varchar(36),
@streamCode varchar(100),
@cycle varchar(20)
set @config_id = '0E6BBCB2-F5AD-4C8A-BF0B-8ADFD1876289'
set @streamCode = '887'
set @cycle = 'xx2019'
update config set query = 'insert into dataset (id, config_id, streamcode, cycle_id)
select newid(), '+@config_id
+', appl.appl_id, appl.cycle_id from appl
inner join cycle on appl.cycle_id = cycle.cycle_id
inner join pref on appl.appl_id = pref.appl_id
inner join stream on pref.course_id = stream.course_id and pref.stream_id = stream.stream_id and appl.num is not null
and stream_code = '+@streamCode
+'and cycle.cycle_code = '+@cycle
where config_id = @config_id