hi friends..
I m using sql server 2008...i m not able to set two auto-increment columns in my table..... Any suggestion please....
Its Urgent...........
Thanks in Advance......................
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Blocked AccountRank #403 · 6.2K reputationPosted May 29, 2012, 2:24 AM EDT
You can't define two identity column in a single table.
Thanks
Manish
sathish kumar115 reputationPosted May 29, 2012, 2:31 AM EDT
brunda kRank #3,804 · 389 reputationPosted May 29, 2012, 2:54 AM EDT
sathish kumar115 reputationPosted May 29, 2012, 3:14 AM EDT
is there any other way to do so......
Anil KumarRank #367 · 6.8K reputationPosted May 29, 2012, 5:27 AM EDT
For Other Column, you can do it by making this column as Compute column. Also you can write Trigger for the same. Easiest and Efficient would be Computed column.
You can create compute column as:
CREATE TABLE myTableName
(
GRNo INT IDENTITY(1,1) NOT NULL,
SecondColumnName VARCHAR(100),
OtherColumnsName VARCHAR(100),
BillNo AS ( 'B' + CAST( GRNo AS varchar(max) ) ) -- filling the value by computing B1 if GRNo is 1
-- OR Simply
-- BillNo AS (GRNo ) -- filling with GRNo
)
Same thing you can do from Design Mode of your table.
Inathi Gqola83 reputationPosted Jul 6, 2015, 6:21 AM EDT
Nigel FernandesRank #753 · 3.1K reputationPosted Dec 21, 2016, 7:45 PM EST