Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Feb 24, 2012 12:51 PM|LINK
using sql server 2005
I have a stored procedure with a temp table where I am trying to insert values as shown below but when I do so I am getting an error, it seems that my single quotes are off, does anyone know the correct syntax that I need to do?
Msg 105, Level 15, State 1, Line 1
Unclosed quotation mark after the character string ',TestC)'.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ',TestC)'.
and the code that is causing the error:
DECLARE @DynamicINSERTSQL nvarchar(300)
DECLARE @VarA nvarchar(50)
DECLARE @VarB NVARCHAR(2)
DECLARE @VarC nvarchar(50)
--I am setting the variable values after I declare them
SET @VarA = 'Test A'
SET @VarB = 'Test B'
SET @VarC = 'Test C'
--this is the line below that errors out
SET @DynamicINSERTSQL = 'INSERT INTO #MyTempTable(ColumnA, ColumnB, ColumnC) VALUES (''' + @VarA + ''',' + @VarB + ''',' + @VarC + ')'