Forcing an IDENTITY column to have a certain value

Forcing an IDENTITY column to have a certain value

am 27.06.2007 22:11:50 von weyus

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

Re: Forcing an IDENTITY column to have a certain value

am 27.06.2007 22:28:51 von tu_wstaw_moje_imie

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

Re: Forcing an IDENTITY column to have a certain value

am 27.06.2007 23:02:19 von weyus

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

Re: Forcing an IDENTITY column to have a certain value

am 28.06.2007 21:31:37 von Gert-Jan Strik

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