Click here to Skip to main content
15,878,231 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Sir,

Table name is cc

Slno	    Glno	Name
	    1010	Jaya
	    1010	Jaya
	    1010	Jaya
	    1011	Koti
	    1011	Koti
	    1012	Pavan
	    1012	Pavan


i want to be update like

Slno	Glno	Name
1	1010	Jaya
2	1010	Jaya
3	1010	Jaya
1	1011	Koti
2	1011	Koti
1	1012	Pavan
2	1012	pavan


glno is a field

the glno have 3 transactions then slno column update to first transaction 1
second is 2
and third is 3
same as another glno have 2 transactions slno update to 1,2

above table have no primary keys


Can u help this
Posted
Updated 18-Sep-11 20:45pm
v2
Comments
Prerak Patel 19-Sep-11 2:45am    
Added text blocks.
JKChowdary 19-Sep-11 2:53am    
Can u send Example code

1 solution

I think a select query is possible.
check this if it works for you

SQL
select 
ROW_NUMBER() over(partition by Glno, Name order by Glno, Name) Slno, Glno, Name
from cc


Try this
SQL
select 
ROW_NUMBER() over(partition by Glno, Name order by Glno, Name) Slno, Glno, Name
into ccTemp from cc
go
drop table cc
go
sp_rename 'ccTemp','cc'
go
select Slno, Glno, Name from CC
 
Share this answer
 
v2
Comments
JKChowdary 19-Sep-11 7:48am    
Thanks for sent its very useful to me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900