if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fn_StrToTable]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[fn_StrToTable]
GO
Create Function fn_StrToTable(@djbh int)
Returns @tableName Table
(
billno int,
billsn int,
num int
)
As
Begin
declare @billno int
declare @billsn int
declare @num int
declare @index int
declare pcurr cursor for select billno,billsn,num from purindt where billno = @djbh
open pcurr
fetch next from pcurr into @billno,@billsn,@num
while (@@fetch_status = 0)
begin
set @index = 0
begin
while (@index < @num)
begin
Insert @tableName Values(@billno,@billsn,1)
set @index = @index + 1;
end
end
fetch next from pcurr into @billno,@billsn,@num
end
close pcurr
deallocate pcurr
Return
End
drop function [dbo].[fn_StrToTable]
GO
Create Function fn_StrToTable(@djbh int)
Returns @tableName Table
(
billno int,
billsn int,
num int
)
As
Begin
declare @billno int
declare @billsn int
declare @num int
declare @index int
declare pcurr cursor for select billno,billsn,num from purindt where billno = @djbh
open pcurr
fetch next from pcurr into @billno,@billsn,@num
while (@@fetch_status = 0)
begin
set @index = 0
begin
while (@index < @num)
begin
Insert @tableName Values(@billno,@billsn,1)
set @index = @index + 1;
end
end
fetch next from pcurr into @billno,@billsn,@num
end
close pcurr
deallocate pcurr
Return
End