今天写一个小存储过程,呵呵!功能大家试一下就知道了。
create proc proc_test
@uid int=0 output,
@uname nvarchar(50)=null output
as
begin
declare dd cursor scroll for
select uid,uname from steven
open dd
fetch first from dd into @uid,@uname
while (@@FETCH_STATUS = 0)
begin
--打印所有循环的值
--print @uid
--print @uname
update brain set username=@uname where uid=@uid
fetch next from dd into @uid,@uname
end
close dd
DEALLOCATE dd
end
create proc proc_test
@uid int=0 output,
@uname nvarchar(50)=null output
as
begin
declare dd cursor scroll for
select uid,uname from steven
open dd
fetch first from dd into @uid,@uname
while (@@FETCH_STATUS = 0)
begin
--打印所有循环的值
--print @uid
--print @uname
update brain set username=@uname where uid=@uid
fetch next from dd into @uid,@uname
end
close dd
DEALLOCATE dd
end