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 2005 Forums
 SQL Server Administration (2005)
 Records being inserted into Gaps of Identity Col

Author  Topic 

ankitbhurat
Starting Member

9 Posts

Posted - 2008-01-17 : 00:19:42
I have a table with the following specifications:

[FutureArticleId] [bigint] IDENTITY(1,1) NOT NULL,
[cFutureArticleTitle] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[cDescription] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[gCategoryId] [bigint] NOT NULL,
[cKeyword] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[bIsDeleted] [bit] NOT NULL CONSTRAINT [DF_tbl_FutureArticle_bIsDeleted] DEFAULT ((0)),
[tOnCreated] [datetime] NOT NULL,
[tOnUpdated] [datetime] NULL,
[gCreatedBy] [bigint] NOT NULL,
[gUpdatedBy] [bigint] NULL,

After some insertions and deletion from the UI, obviously there are gaps in the FutureArticleId column which is an identity column.

However, sometimes while inserting the records the records are being inserted into the gap and not in the next available Identity value.

Is there any table setting which I need to do, to stop this.

Please let me know

Thanks
Ankit

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-01-17 : 02:27:04
This is not possible, unless you are using the SET IDENTITY INSERT {TableName} {ON | OFF}



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

ankitbhurat
Starting Member

9 Posts

Posted - 2008-01-17 : 04:03:01
i did SET IDENTITY_INSERT TableName ON

but it is still inserting in the gap.
Ankit

quote:
Originally posted by Peso

This is not possible, unless you are using the SET IDENTITY INSERT {TableName} {ON | OFF}



E 12°55'05.25"
N 56°04'39.16"


Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-01-17 : 05:02:01
Yes it is, because you use the SET IDENTITY clause.
Read about this clause in Books Online and what it does.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -