日期:2014-05-18 浏览次数:20528 次
id value ---------------------------------------------------- 1 2 2 4 3 8
declare @str varchar(20) set @str='' ;with t as( select 1 as id,2 as value union all select 2 ,4 union all select 3,8 ) select @str=@str+'^'+ltrim(value) from t select right(@str,len(@str)-1) as value value 2^4^8
------解决方案--------------------
declare @str int ;with t as( select 1 as id,2 as value union all select 2 ,4 union all select 3,8 ) select @str=isnull(@str,0)^value from t select @str /*----------- 14 (1 行受影响) */