Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem passing XML Parameter to SQL Server Stored Procedure

I am trying to create a stored procedure that accepts XML data as an input parameter but cannot get it to compile. The Code:

CREATE PROCEDURE dbo.idn_UpdateUserApplications
(
    @AppIdList xml,
    @UserID nvarchar(256),
    @ModifiedBy nvarchar(256)
)

AS

BEGIN
    SET NOCOUNT ON

    INSERT INTO userapplication 
                (userid, 
                 modifiedby, 
                 modifiedon,
                 appid) 
    SELECT @UserID as userid, 
           @ModifiedBy As modifiedby, 
           Getdate() as modifiedon,
           paramvalues.id.VALUE('.', 'VARCHAR(20)') AS appid 
    FROM   @AppIdList.NODES('/Applications/id') AS paramvalues(ID)   
END 

The Error: Msg 317, Level 16, State 1, Procedure idn_UpdateUserApplications, Line 13 Table-valued function 'NODES' cannot have a column alias.

like image 355
Jim Evans Avatar asked Jun 21 '11 19:06

Jim Evans


Video Answer


1 Answers

NODES and VALUE needs to be lower case nodes, value.

like image 74
Mikael Eriksson Avatar answered Sep 28 '22 03:09

Mikael Eriksson