sql 数据库根据数量拆分为与数量相等的行数(函数)
来源:互联网 发布:linux中tcpdump 用法 编辑:程序博客网 时间:2024/06/07 04:59
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
0 0
- sql 数据库根据数量拆分为与数量相等的行数(函数)
- insert select 根据数量拆分多行
- 计算总的行数/数量
- sql server 获得数据库中表数量和字段数量的语句
- 取得连接sql server中某个数据库的客户端数量
- 数据库统计不同字段数量时的sql语句
- sql server 的连接数量
- 求多个库的数量总和sql
- sql server如何查看数据库的状态信息(比如表的数量)?
- 根据乘客数量得到信息框的
- 不定数量参数的函数
- 数量
- 数量
- 拆分字符串的SQL数据库函数
- mysql数据库根据datetime数据查询某一时间区间的数据数量
- MSSQL 中双重循环实现发货数量的拆分
- 查找一表中一字段记录集行数相同的数量
- Java代码 统计项目的文件数量,和代码行数
- 二维计算几何基础
- 第二章 应用服务器调优
- hdu 4405 Aeroplane chess 概率dp
- BEA WebLogic平台下J2EE调优攻略----第三章 数据库调优
- Cannot change version of project facet Dynamic Web Module to 2.5
- sql 数据库根据数量拆分为与数量相等的行数(函数)
- 第四章 操作系统调优
- 使用mysql中的函数快速插入测试数据
- Linux 2.6.19.x 内核编译配置选项简介
- 【网络安全】Bash漏洞原理POC及ShellCode
- Android AlertDialog 动态更新弹出框中的内容
- BEA WebLogic平台下J2EE调优攻略----第五章 性能监控和性能分析
- Linux常用命令详解
- cocos2d-x CocoStudio中场景触发器(Trigger)的代码部分和触发器之间的互调