---游标
create proc myproc
as
declare @id int
declare @name varchar(50)
declare cursor1 cursor for
select * from table1
open cursor1
fetch next from cursor1 into @id,@name
declare @aa varchar(100)
set @aa=''
while @@fetch_status=0
begin
set @aa=@aa+','+@name
fetch next from cursor1 into @id,@name
end
select id,[name],@aa as val from table1
close cursor1
deallocate cursor1
游标
最新推荐文章于 2022-10-27 14:46:34 发布