Within a stored procedure, I am trying to execute an insert statement which contains variables. The code for the insert is below:
select @insertstatement = * 'insert into KbText_' + @appid select ''Yes'', ' + @vtext1 + @vtext2 + @vtext3 + @vtext4 + @vtext5 + @vtext6 + ' TextData ', + @appid
exec(@insertstatement)
I keep getting the following error:
Error 141: A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
How can I execute an insert statement which has variables?
Thanks!
select @insertstatement = * 'insert into KbText_' + @appid select ''Yes'', ' + @vtext1 + @vtext2 + @vtext3 + @vtext4 + @vtext5 + @vtext6 + ' TextData ', + @appid
exec(@insertstatement)
I keep getting the following error:
Error 141: A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
How can I execute an insert statement which has variables?
Thanks!