创建一个新的(自定义)数据库函数
2008-04-28 15:24
155 查看
/*--创建一个新的数据库函数(用于同一字段相加,此字段为字符型)
--date :2008-04-09
--Author :wangh
-- 参数 @productno int 产品内码
-- return 格式如:3040,3043,3486|3040,3242,3517
*/
CREATE function [dbo].[func_str_sum](@productno int)--修改
returns varchar(8000)
as
begin
declare @str varchar(8000)
set @str=''
select @str=@str+'|'+ keys.ComposeCode1
from Fm_Pd_Productkey keys where keys.isValidate=1 and keys.deleteTime is null and keys.keyType=1002 and keys.productInnerNo=@productno
return(stuff(@str,1,1,''))
end
A表
id ProductInnerNo ComposeCode1
1 1001 3040,3043,3486
2 1002 3040,3242,3517
调用函数后可返回 3040,3043,3486|3040,3242,3517
--date :2008-04-09
--Author :wangh
-- 参数 @productno int 产品内码
-- return 格式如:3040,3043,3486|3040,3242,3517
*/
CREATE function [dbo].[func_str_sum](@productno int)--修改
returns varchar(8000)
as
begin
declare @str varchar(8000)
set @str=''
select @str=@str+'|'+ keys.ComposeCode1
from Fm_Pd_Productkey keys where keys.isValidate=1 and keys.deleteTime is null and keys.keyType=1002 and keys.productInnerNo=@productno
return(stuff(@str,1,1,''))
end
A表
id ProductInnerNo ComposeCode1
1 1001 3040,3043,3486
2 1002 3040,3242,3517
调用函数后可返回 3040,3043,3486|3040,3242,3517
相关文章推荐
- NSIS ---使用nsDialogs创建自定义页面,并获取输入到控件中的内容保存到一个XML文档中
- 直接创建一个DataTable,并为之添加数据(自定义DataTable)
- 创建一个自定义的Spring Boot Starter
- 如何创建一个自定义帐户来运行 ASP.NET
- Dockerfile用来创建一个自定义的image图示
- 如何给magento的产品分类创建一个自定义属性?
- C# 直接创建一个DataTable,并为之添加数据(自定义DataTable) 转
- WCF 第四章 绑定 创建一个自定义绑定
- 【Unity灯光与渲染技术】在Unity3D中创建一个自定义的天空盒子setting up a custom skybox
- android自定义View创建一个Path绘制多边形,贝塞尔曲线,
- 使用python创建一个检测不到的自定义SSH后门
- Duilib 入门教程: 怎么创建一个自定义的窗口
- 创建一个自定义ToolPart
- 【Android Trainning 翻译】创建自定义View之创建一个自定义View类
- 自定义View,创建一个小圆点,单击可以拖动
- Ionic2创建一个自定义pipe实现千分位号
- Enterprise Library深入解析与灵活应用(4):创建一个自定义Exception Handler改变ELAB的异常处理机制
- jquery创建一个新的节点对象(自定义结构/内容)的好方法
- 一个使用c++在lua中创建自定义数据类型的简易方法