December 19, 2010 at 11:21 pm
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?
December 20, 2010 at 12:57 am
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, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
December 20, 2010 at 4:50 am
thanks a lot gail....
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply