July 2, 2003 at 5:56 pm
I create a table T1 as follows:
CREATE TABLE [dbo].[T1] (
[ID] [int] IDENTITY (1,1) NOT NULL,
[NAME] [varchar] (30)
) ON PRIMARY
ALTER TABLE [dbo].[T1] WITH NO CHECK ADD
CONSTRAINT [T1_ID] PRIMARY KEY CLUSTERED ([ID])) ON [PRIMARY]
Is it possible to programmatically disable the IDENTITY property of ID, insert a few records with ID specified and finally restore IDENTITY(1,1)?
I tried
ALTER TABLE T1 ALTER COLUMN [ID] ...
but the syntax for disabling and later enabling IDENTITY doesn't work.
Thanks.
July 2, 2003 at 6:50 pm
See BOL 2000:
SET IDENTITY_INSERT
Allows explicit values to be inserted into the identity column of a table.
July 3, 2003 at 5:38 pm
Don't forget that only one table can have identity_insert set on at a time, and that the user account running set identity_insert must have db_owner permissions.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply