|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, October 31, 2012 1:16 AM
Points: 127,
Visits: 348
|
|
create table #test_table(sno int identity(1,1),line_no int null,product_name varchar(20)) insert into #test_table(product_name) values('TV') insert into #test_table(product_name) values('Mobile') insert into #test_table(product_name) values('Webcam') insert into #test_table(product_name) values('Keyboard')
Now i need line_no column incremented by 1 starting from 1.... using update command in ascending order of sno column.....
any help pls?
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 3:18 PM
Points: 37,744,
Visits: 30,025
|
|
The Row_Number function will do what you want. First write a select that returns the data you what, then use that in the from clause of the update.
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, October 31, 2012 1:16 AM
Points: 127,
Visits: 348
|
|
|
|
|