how set identity specification column in sql server 2008
? need set seed "st000".
please me.
do mean:
create table dbo.yourtable ( id int identity(1,1) not null, ....other columns here.....
just use identity
keyword - can specify seed (starting value) , increment - typically, both set 1
(but don't have to).
for more details, see msdn sql server books online documentation identity
if need have non-numeric column sort of behaves identity
, i'd suggest use above approach, , define column this:
create table dbo.yourtable ( id int identity(1,1) not null, idwithprefix 'st' + right('0000' + cast(id varchar(4)), 4) persisted, ....other columns here.....
that way, id
column automatically values 1, 2, 3, 4, 5....... , idwithprefix
column have st0001
, st0002
, forth.
Comments
Post a Comment