Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
declare @v varchar(500)
set @v = ''
SELECT @v = OperateCode
FROM
(
SELECT 'd' operatecode
union all select 'e'
) T1
select @v
结果为 ‘e’ 即:这种赋值方式会遍历所有记录,将记录一一赋给@v,@v的值为最后一个。可利用这一特性,将一列转换到一格中存储
declare @v varchar(500)
set @v = ''
SELECT @v = @v + OperateCode + ‘,’
FROM
(
SELECT 'd' operatecode
union all select 'e'
) T1
select @v
结果为:d,e