March 7, 2008 at 11:47 am
hi guys can anyone tell me if they see something wrong with this line
SET IDENTITY_INSERT ''+ @TABLENAME + ' ' ON
INSERT INTO ' '+ @TABLENAME +' '
it keeps telling me :
Incorrect syntax near ''.
:w00t:
March 7, 2008 at 12:14 pm
i have sorry i should had put the whole code
SET NOCOUNT ON
DECLARE @TABLENAME VARCHAR(255)
select @TABLENAME='customers_'+ CONVERT(CHAR(4),YEAR(GETDATE()) -1)
SET IDENTITY_INSERT '+ @TABLENAME + ' ON
INSERT INTO '+ @TABLENAME'
i tried changing it to single quotes and i get the same error.
March 7, 2008 at 12:18 pm
You have to create you statement as a string and execute it via exec or sp_executesql. Look at my example above.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply