drop table room create table room ( id int , age varchar(5), pwd varchar(5) )
insert into room values(1,'8888','9999') insert into room values(5,'0','0') insert into room values(4,'0','0') insert into room values(31,'0','0') insert into room values(2,'0','0')
drop procedure update_room create procedure update_room @iid int output as declare @id int select top 1 @id=id from room where age='8888' and pwd='9999'
update room set age='0' , pwd='0' where @id=id select top 2 @id=id from room where age='0' and pwd='0'
update room set age='8888' , pwd='9999' where @id=id go
select * from room declare @iid int exec update_room @iid output print("--------->"+@iid);