Hi.
I am trying to execute the following statement with a variable:
I'm trying to do this with a variable, but since my script ends in a single quote: ' I can't find a correct syntax to make this work. So far I have:
I get an 'incorrect syntax' message. I know there has to be an easy fix here but I am stumped.
Thanks!
Brian
I am trying to execute the following statement with a variable:
Code:
update lintest..mytable1
set countervalue = (select max (id)+1 from lintest..acres)
where countername = 'acres'
I'm trying to do this with a variable, but since my script ends in a single quote: ' I can't find a correct syntax to make this work. So far I have:
Code:
declare @destination varchar(20)
set @destination = 'lintest'
declare @acresupdate varchar(100)
set @acresupdate = 'update ' + @destination + '..mytable1
set countervalue = (select max (id)+1 from ' + @destination + '..acres)
where countername = ' + '''' + 'acres' + ''''
execute (@acresupdate)
I get an 'incorrect syntax' message. I know there has to be an easy fix here but I am stumped.
Thanks!
Brian