SQL Server 自定义函数(1)把某一列多行的值拼接成一个字符串

DECLARE @resultstr VARCHAR(8000)
SET @resultstr=''
SELECT @resultstr=@resultstr+'|'+[BaseImage] FROM dbo.life_fc
PRINT @resultstr

示例2

DECLARE @imgColleciton VARCHAR(8000),@BaseID INT,@value VARCHAR(5000),@citcode VARCHAR(100),@type VARCHAR(100)
SET @imgColleciton=''
SELECT @citcode=BaseCityCode FROM dbo.life_fc
SELECT @type= BaseTypeID FROM dbo.life_fc
SELECT @imgColleciton=@imgColleciton+'|'+[BaseImage] FROM dbo.life_fc
SELECT 'E:\cityresource7\cn\'+@citcode+'\zh-chs\etongcheng\'+cast(@type as varchar(8))+'\img'+value FROM [dbo].[SplitString](@imgColleciton,'|',0)
上一篇:不能为虚拟电脑 ubuntu 打开一个新任务.


下一篇:RoutePrefix和Route 路由前缀