CREATE PROCEDURE sp_mytest1
@mytype int
AS
declare @pro varchar(50)
declare @pro1 varchar(50)
select @pro=typename from table1 where [id]=@mytype
declare wu Cursor for select product from table2 where [typename]=@pro
open wu
set @pro1=''
fetch next from wu into @pro
while @@fetch_status=0
begin
set @pro1=@pro1+@pro+','
fetch next from wu into @pro
end
close wu
set set @pro1=substring(@pro1,0,len(@pro1))
deallocate wu
insert into table3 values(@mytype,@pro1)
GO
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)