Click here to Skip to main content
16,019,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a columns workid,appid,stepno in my table "Work_Table". Workid is primary key.
my table like this.

workid appid , stepno
1 1 1
2 1 2
3 1 3
4 2 1
5 2 2
6 2 3
7 2 4
9 2 5
10 3 1
11 3 2

Every appid has repeated stepno's. Well my problem is ,when i delete one stepno by using workid, the rest of stepno's should be auto decrement in that appid.

ex: if i delete workid- 5, then stepno's in that appid-2 would decrement like 1,2,3,4

I want to do this in by using linq.

Can anyone help me.
Posted

1 solution

Hi,

Try the following

delete from your table name where workid=@workid and stepno=(select max(stepno) from test where workid=@workid)


Hope this helps....
 
Share this answer
 
Comments
ganesh_kanc 20-Dec-11 4:38am    
Hi sriman ,
Thanks for the reply, but i want to do this in linq.
sriman.ch 20-Dec-11 23:13pm    
Have a look on the following link


http://msdn.microsoft.com/en-us/library/bb386925.aspx

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