任何正文都可以帮助我,为什么我会收到此错误" FOR XML ROW附近的语法错误,
在此标量函数中
ALTER
FUNCTION [DBO].[GetBaseTypeProductsAsXml](
@CountryID INT ,
@BaseTypeID INT = -1 ) RETURNS XML
AS
BEGIN
DECLARE
@Result XML;
SELECT @Result =
(SELECT TOP 10 BP.Id AS BaseProductId,
BP.Name AS ProductName,
Product.StartingPrice AS Price,
HeaderImage.Path AS ImagePath
FROM [BaseProducts] BP
INNER JOIN [Products] Product
ON (BP.Id = Product.BaseProductId
AND Product.CountryId = @CountryID) OUTER APPLY
(SELECT TOP 1 HeaderImage.[Path]
FROM [DBO].Images AS [HeaderImage]
INNER JOIN [DBO].ProductsImages AS ProductsImages
ON HeaderImage.Id = ProductsImages.ImageId
WHERE ProductsImages.BaseProductId = BP.Id
ORDER BY [ProductsImages].[ORDER]
) AS HeaderImage
WHERE BP.TypeId = @BaseTypeID FOR XML ROW 'Error is here'
)
RETURN @Result;
END
由于
答案 0 :(得分:2)
如果这是SQL Server,则没有FOR XML Row
。你的意思是XML Raw
。否则,要表示结果集中的每一行,您只需说出FOR XML Path
。