Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
CSK
Constraint Violating Yak Guru
489 Posts |
Posted - 2006-08-31 : 01:39:32
|
Dear All,I need to Update the Sno Based on the DeptCan Any one suggest me please..?Create Table #temp ( Sno int, Dept Varchar(1), Emp_Code Varchar(1) )Insert into #Temp ( Dept, Emp_Code ) Select 'A','1' Union All Select 'A','2'Union All Select 'A','3'Union All Select 'A','4'Union All Select 'A','5'Union All Select 'B','1'Union All Select 'B','2'Union All Select 'B','3'Union All Select 'B','4'Union All Select 'B','5'Union All Select 'C','1'Union All Select 'C','2'Union All Select 'D','1'Union All Select 'D','2'Union All Select 'D','3'thanks and regardskrishna |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-08-31 : 01:47:41
|
like this ?update #tempset Sno =(select count(*) from #temp x where x.Dept =t.Dept and x.Emp_Code <= t.Emp_Code)from #temp t KH |
 |
|
CSK
Constraint Violating Yak Guru
489 Posts |
Posted - 2006-08-31 : 01:50:18
|
Yes Thanks KHTAN. I expect The Same Result as U doneThank you Very Much |
 |
|
|
|
|
|
|