SQL拼接查询结果的原理?

xeon_pan xeon_pan 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

create table #
(id varchar(10))
insert into #
select 'a' union all
select 'b' union all
select 'c' union all
select 'd'

declare @s varchar(100)
select @s=''
select @s=@s+id from #
print @s

abcd


这里面

select @s=@s+id from #

为什么可以拼字符串呢?
我个人理解 这个应该会是分解为 select id from #
和 @s = @s+select id from #
这样的话

select id from #应该返回的是表啊?
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
xeon_pan
MS-SQL Server 34,876 成员 254,635 内容