3

This is the code:

declare @Ids table ( Id int identity(1,1));

SET IDENTITY_INSERT @Ids ON;

and I get:

Incorrect syntax near '@Ids'

I cannot see what's wrong. Any ideas? Thanks.

1 Answer 1

8

You can't use SET IDENTITY_INSERT on table variables

This works

CREATE TABLE Ids ( Id int identity(1,1))
SET IDENTITY_INSERT Ids ON

and this

CREATE TABLE #Ids ( Id int identity(1,1))
SET IDENTITY_INSERT #Ids ON
Sign up to request clarification or add additional context in comments.

1 Comment

Oops. Thanks. Should have read on here: sqlteam.com/forums/topic.asp?TOPIC_ID=61808

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.