i have a problem with identity column...i have two columns reg_series ans reg_number...i have set reg_series with current system date...and i have to get increment in reg_number based on reg_series...output shud be like this
reg_series reg_number
20121116 1
20121116 2
20121116 3
20121116 4
20121117 1
20121117 2
20121117 3
declare @date varchar(50)
set @date=convert(varchar(50),GETDATE(),112)
insert into data(Reg_Series) values(@date)
i have set reg_series with current system date...reg_number shud be auto generated based on reg_series value
I have a problem with identity column
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Prasant JinagaRank #2,383 · 594 reputationPosted Nov 16, 2012, 5:19 AM EST
If you want to set AutoIncrement for a column
CREATE TABLE dbo.Tmp_Names ( reg_number int NOT NULL IDENTITY(1, 1), reg_series varchar(50) NULL) ON [PRIMARY] If you want to insert the values into the table you can directly insert into the table by specifying the column name Insert into Tmp_Names(reg_series) values (convert(varchar(50),GetDatetimeOffset(),112)) The reg_number value will be automatically incremented... Thanks, Prasant