William Ortenberg <billort@pacbel l.net> wrote in message news:<v%FYa.272 4$yF6.589@newss vr22.news.prodi gy.com>...[color=blue]
> Can I change the value of a column's identity seed programmaticall y? If
> so, how?
>
> Thanks in advance.[/color]
You can use DBCC CHECKIDENT with RESEED, but the new value is not
permanent. If you truncate the table, the seed will return to the
original value specified when you created the table.
If you want to change the seed value permanently, then you'll have to
recreate the table with the new seed specified in the column
definition.
Simon
create table dbo.t (
col1 int identity(1,1)
)
insert into t default values
select scope_identity( ) -- 1
dbcc checkident(t, RESEED, 5)
insert into t default values
select scope_identity( ) -- 6
truncate table dbo.t
insert into t default values
select scope_identity( ) -- 1
Comment