hello sir,
Please tell me how to update records in a table automatically in SQL.
Actually i want that if i delete a record from a table which has Serial
No. as primary key, then all other records should update automatically
means there Serial No. should be updated in sequence(1,2,3,4,5).
thanks
*** Sent via Developersdex http://www.codecomments.com ***Hi
I assume SerialNo is not an identity ...
create table e(j int ,i int)
insert e select 1, 3 union select 2, 7 union select 3,10 union select 4,20
select * from e
go
--delete the row
delete from e where j=2
--run this immeditaly
declare @.k int
set @.k=0
update e
set @.k=j=@.k+1
select * from e
go
drop table e
"ramji gupta" <gupta.rnd@.gmail.com> wrote in message
news:%23x%23m%2349tHHA.4948@.TK2MSFTNGP06.phx.gbl...
> hello sir,
> Please tell me how to update records in a table automatically in SQL.
> Actually i want that if i delete a record from a table which has Serial
> No. as primary key, then all other records should update automatically
> means there Serial No. should be updated in sequence(1,2,3,4,5).
> thanks
> *** Sent via Developersdex http://www.codecomments.com ***
No comments:
Post a Comment