deepthi gollapalli deepthi gollapalli - 19 days ago 8
SQL Question

SQL Server: Auto increment decimal column

I need to auto increment a decimal column in SQL Server 2014.

Answer

My actual requirement is to generate a version number for each call of my stored procedure. I have implemented this as below.

Did creation and updation of table externally

create table version(no decimal(2,2)) insert into version(1.0)

Below is the small extract of my stored procedure

Update version set no=(select max(no) from version)+1

select no.version,t.* from table t left join version

Comments