将XML参数传递给SQL Server存储过程的问题

时间:2011-06-21 19:48:03

标签: xml sql-server-2005

我正在尝试创建一个存储过程,它接受XML数据作为输入参数但无法进行编译。守则:

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 

错误: 消息317,级别16,状态1,过程idn_UpdateUserApplications,第13行 表值函数'NODES'不能有列别名。

1 个答案:

答案 0 :(得分:7)

NODESVALUE必须为小写nodesvalue