Unix Technical Forum

Forcing an IDENTITY column to have a certain value

This is a discussion on Forcing an IDENTITY column to have a certain value within the SQL Server forums, part of the Microsoft SQL Server category; --> All, Is there any way to _set_ an IDENTITY column to have a certain value so as to create ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2008, 03:23 PM
Weyus
 
Posts: n/a
Default Forcing an IDENTITY column to have a certain value

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 03:23 PM
Marcin A. Guzowski
 
Posts: n/a
Default Re: Forcing an IDENTITY column to have a certain value

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 Guzowski
http://guzowski.info
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-01-2008, 03:23 PM
Weyus
 
Posts: n/a
Default Re: Forcing an IDENTITY column to have a certain value

On Jun 27, 3:28 pm, "Marcin A. Guzowski"
<tu_wstaw_moje_i...@guzowski.info> wrote:
> 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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-01-2008, 03:23 PM
Gert-Jan Strik
 
Posts: n/a
Default Re: Forcing an IDENTITY column to have a certain value

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:
>
> 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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:17 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com