c# - How to set Identity Specification YES in 2 columns in a table in SQL Server 2008 -
how set identity specification yes in 2 columns in table in sql server 2008 ?
example:
id int, catid int, for "@id" using primary key , set identity yes. allow not null.
for "@catid" want set identity yes also,
but when set identity yes "@catid" column, "@id" column becomes identity no itself.
i want @catid generate id @id.
check picture attached plz. , suggest me

it seems having table design issues. why have 2 identity columns? stated in comments, values either same or computable original identity specification:
create table mytable ( id int identity(1,1) not null primary key, catid id, -- computed column myfield nvarchar(100) null ) yields:
id catid myfield 1 1 2 2 b 3 3 c 4 4 d 5 5 e now if have different value catid:
create table mytable ( id int identity(1,1) not null primary key, catid id * 3, -- different value myfield nvarchar(100) null ) we get:
id catid myfield 1 3 2 6 b 3 9 c 4 12 d 5 15 e either way never makes sense have multiple identity columns.
Comments
Post a Comment