SQL Server把某一列多行的值拼接成一个字符串 的原理是什么
DECLARE@resultstrVARCHAR(8000)SET@resultstr=''SELECT@resultstr=@resultstr+'|'+[name]F...
DECLARE @resultstr VARCHAR(8000)
SET @resultstr=''
SELECT @resultstr=@resultstr+'|'+[name] FROM tb
PRINT @resultstr
SELECT @resultstr=@resultstr+'|'+[name] FROM tb 这句是什么意思 展开
SET @resultstr=''
SELECT @resultstr=@resultstr+'|'+[name] FROM tb
PRINT @resultstr
SELECT @resultstr=@resultstr+'|'+[name] FROM tb 这句是什么意思 展开
展开全部
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)
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)
追问
SELECT @resultstr=@resultstr+'|'+[BaseImage] FROM dbo.life_fc 是什么原理
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询