deepthi gollapalli deepthi gollapalli - 1 year ago 141
SQL Question

SQL Server: Auto increment decimal column

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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download