2014-05-15 3 views
0

peut me aider tout organisme pourquoi j'obtiens cette erreur « syntaxe incorrecte près ROW XML,syntaxe incorrecte près ROW XML,

dans cette Scalar Fonction

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 

Merci

+0

Quelle base de données? Il ressemble à SQL Server (2008, 2012?) – tgolisch

+0

Oui c'est SQL Server 2012 – user123456

Répondre

2

Si il s'agit de SQL Server, il n'y a pas de FOR XML Row.Par exemple, vous voulez dire XML Raw, sinon, pour représenter chaque ligne dans un jeu de résultats, vous pouvez simplement dire FOR XML Path

+0

Oui c'est SQL Server 2012 – user123456

+0

Merci pour votre réponse – user123456