dbTalk Databases Forums  

Forcing an IDENTITY column to have a certain value

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Forcing an IDENTITY column to have a certain value in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Weyus
 
Posts: n/a

Default Forcing an IDENTITY column to have a certain value - 06-27-2007 , 03:11 PM






All,

Is there any way to _set_ an IDENTITY column to have a certain value
so as to create a gap in the set of identity values on purpose?


All I've found is SET IDENTITY_INSERT.

Thanks,
Wes


Reply With Quote
  #2  
Old   
Marcin A. Guzowski
 
Posts: n/a

Default Re: Forcing an IDENTITY column to have a certain value - 06-27-2007 , 03:28 PM






Weyus wrote:
Quote:
All,

Is there any way to _set_ an IDENTITY column to have a certain value
so as to create a gap in the set of identity values on purpose?


All I've found is SET IDENTITY_INSERT.
There is also a DBCC command:
DBCC CHECKIDENT ('table_name', reseed, new_value)


--
Best regards,
Marcin Guzowski
http://guzowski.info


Reply With Quote
  #3  
Old   
Weyus
 
Posts: n/a

Default Re: Forcing an IDENTITY column to have a certain value - 06-27-2007 , 04:02 PM



On Jun 27, 3:28 pm, "Marcin A. Guzowski"
<tu_wstaw_moje_i... (AT) guzowski (DOT) info> wrote:
Quote:
Weyus wrote:
All,

Is there any way to _set_ an IDENTITY column to have a certain value
so as to create a gap in the set of identity values on purpose?

All I've found is SET IDENTITY_INSERT.

There is also a DBCC command:
DBCC CHECKIDENT ('table_name', reseed, new_value)

--
Best regards,
Marcin Guzowskihttp://guzowski.info
Thanks,
That's what I needed!

Wes



Reply With Quote
  #4  
Old   
Gert-Jan Strik
 
Posts: n/a

Default Re: Forcing an IDENTITY column to have a certain value - 06-28-2007 , 02:31 PM



If you only need small gaps, you could simply do this:

BEGIN TRANSACTION

INSERT INTO my_table DEFAULT VALUES

ROLLBACK TRANSACTION


HTH,
Gert-Jan


Weyus wrote:
Quote:
All,

Is there any way to _set_ an IDENTITY column to have a certain value
so as to create a gap in the set of identity values on purpose?

All I've found is SET IDENTITY_INSERT.

Thanks,
Wes

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.