DECLARE @guidList NVARCHAR(max)
SELECT @guidList=( CAST(OrderGUID AS nvarchar(max)) +',')
FROM OrderWareHouse.dbo.OrderDetail
FOR XML PATH('')
将XML Paht('')查询出来的结果赋值给@guidList 变量此时会出错:不允许 ASSIGNMENT 语句中包含 FOR XML 子句。
修改为:
set @guidList=(SELECT (CAST(OrderGUID AS nvarchar(max)) +',')
FROM OrderWareHouse.dbo.OrderDetail
FOR XML PATH(''))
PRINT @guidList
SELECT @guidList=( CAST(OrderGUID AS nvarchar(max)) +',')
FROM OrderWareHouse.dbo.OrderDetail
FOR XML PATH('')
将XML Paht('')查询出来的结果赋值给@guidList 变量此时会出错:不允许 ASSIGNMENT 语句中包含 FOR XML 子句。
修改为:
set @guidList=(SELECT (CAST(OrderGUID AS nvarchar(max)) +',')
FROM OrderWareHouse.dbo.OrderDetail
FOR XML PATH(''))
PRINT @guidList