create function digui(@dq varchar(50),@nf varchar(50),@nd varchar(50))
returns @dqmchs table
(dqmc varchar(50),nf varchar(50),nd varchar(50))
as
begin insert @dqmchs
select a.dq,a.nf,a.nd from table1 a, table2 b where b.dq=@dq and
a.dq=b.dq and nf=@nf and nd=@nd
if exists(select a.dq,a.nf,a.nd from table1 a, table2 b where b.dq=@dq and a.dq=b.dq and nf=@nf and nd=@nd)
begin
declare @youbiao1 varchar(50)
declare @youbiao2 varchar(50)
declare @youbiao3 varchar(50)
declare youbiao cursor for
select a.dq,a.nf,a.nd from table1 a, table2 b where b.dq=@dq and
a.dq=b.dq and nf=@nf and nd=@nd
for read onlyopen youbiao
fetch youbiao into @youbiao1,@youbiao2,@youbiao3while @@fetch_Status=0
begin
insert @dqmchs select * from digui(@youbiao1,@youbiao2,@youbiao3) --此处报错,希望大家指点
fetch youbiao into @youbiao1,@youbiao2,@youbiao3
end
close youbiao
deallocate youbiaoend
return
end
?????????????
returns @dqmchs table
(dqmc varchar(50),nf varchar(50),nd varchar(50))
as
begin insert @dqmchs
select a.dq,a.nf,a.nd from table1 a, table2 b where b.dq=@dq and
a.dq=b.dq and nf=@nf and nd=@nd
if exists(select a.dq,a.nf,a.nd from table1 a, table2 b where b.dq=@dq and a.dq=b.dq and nf=@nf and nd=@nd)
begin
declare @youbiao1 varchar(50)
declare @youbiao2 varchar(50)
declare @youbiao3 varchar(50)
declare youbiao cursor for
select a.dq,a.nf,a.nd from table1 a, table2 b where b.dq=@dq and
a.dq=b.dq and nf=@nf and nd=@nd
for read onlyopen youbiao
fetch youbiao into @youbiao1,@youbiao2,@youbiao3while @@fetch_Status=0
begin
insert @dqmchs select * from digui(@youbiao1,@youbiao2,@youbiao3) --此处报错,希望大家指点
fetch youbiao into @youbiao1,@youbiao2,@youbiao3
end
close youbiao
deallocate youbiaoend
return
end
?????????????
select * from dbo.digui(@youbiao1,@youbiao2,@youbiao3)