Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Identity Insert

Author  Topic 

Hommer
Aged Yak Warrior

808 Posts

Posted - 2004-08-09 : 10:20:30
I got an error when runing an insert:
Cannot insert explicit value for identity column in table 'input_queue' when IDENTITY_INSERT is set to OFF.

The table's script is as follow:
CREATE TABLE [dbo].[input_queue] (
[request_id] [varchar] (255),
[priority] [smallint] NULL ,
[submit_date] [datetime] NULL ,
...
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE [dbo].[input_queue] WITH NOCHECK ADD
CONSTRAINT [PK_input_queue] PRIMARY KEY CLUSTERED
(
[request_id]
) ON [PRIMARY]
GO

The request_id does not have to be an identity column. I am confused. Can I have it as my primary key with index but not identity with auto increment?

Your help is appreciated!

mfemenel
Professor Frink

1421 Posts

Posted - 2004-08-09 : 12:15:20
Just for fun, what happens if you try to set the identity_insert to on?

Mike
"oh, that monkey is going to pay"
Go to Top of Page

Hommer
Aged Yak Warrior

808 Posts

Posted - 2004-08-09 : 17:46:58
It will insert the value, but I have to add code to set it on then off.
I thought I could get away of doing that by removing the identity.
Go to Top of Page
   

- Advertisement -