日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

sqlserver連接字符串 sql連接字符串的方法

方案一:
Create FUNCTION [dbo].Get_Contract_StyleNo(@AutoInc bigint)
RETURNS VARCHAR(Max)
【sqlserver連接字符串 sql連接字符串的方法】AS
BEGIN
declare @Content NVARCHAR(MAX)
SET @Content = ”
select @Content = case when @Content=” then ” else @Content + ‘,’ end + GoodsNo
FROM (select distinct GoodsNo from EXP_Contract_Clothing_Goods where MainID=@AutoInc) m
RETURN @Content
END
GO

sqlserver連接字符串 sql連接字符串的方法


構(gòu)造標(biāo)量函數(shù)
sqlserver連接字符串 sql連接字符串的方法


使用xml
sqlserver連接字符串 sql連接字符串的方法


構(gòu)造通用存儲過程
方案三:
——默認(rèn)條件,MainID=AutoInc
alter procedure [dbo].[SP_SumStr]
(
@MTable Varchar(100)–主表
,@ZTable Varchar(100)–子表
,@MColumn Varchar(100)–主表更新字段
,@ZColumn Varchar(100)–子表拼接字段
,@ConditionSql Varchar(500)–傳入的條件語句
)
as
set nocount on
begin
declare @strSql varchar(3000)
select top 1 AutoInc as MainID, Convert(nvarchar(500),CnName) as GoodsNo
into #result
from SYS_Staff where 1<0
set @strSql = ‘insert into #result select distinct MainID,’+ @ZColumn +’ from ‘+@ZTable+’ ‘ + @ConditionSql
exec(@strSql)
declare @Content NVARCHAR(MAX)
SET @Content = ”
select @Content = case when @Content=” then ” else @Content + ‘,’ end + GoodsNo FROM #result
set @strSql = ‘update a set a.’+@MColumn+’=’+@Content+’ from ‘+ @MTable +’ a left join ‘+@ZTable+’ b on a.AutoInc=b.MainID ‘ + @ConditionSql
exec(@strSql)
—-select @Content
end
set nocount off

    推薦閱讀