我声明varchar
变量TSQLTSQL追加行到一个变量
declare @var varchar(max);
我有一个返回多个值的选择查询。如:
Select name from table where ...
我想追加每行到这个变量。例如我的查询返回:
name
----------
Joe
Jack
William
Avarel
我希望我的@var
是这样的:JoeJackWilliamAvarel
我该怎么办呢?我写这篇文章的查询,但它给我的错误:
Set @var = (Select name from table where ...)
和错误是:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
谢谢
其实它是如此简单,我怎么可以不考虑它,谢谢:) – Mehmet