本文介绍了将 XML 参数传递给 SQL Server 存储过程时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个存储过程,该过程接受 XML 数据作为输入参数,但无法对其进行编译.代码:
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
错误:消息 317,级别 16,状态 1,过程 idn_UpdateUserApplications,第 13 行表值函数NODES"不能有列别名.
The Error:Msg 317, Level 16, State 1, Procedure idn_UpdateUserApplications, Line 13Table-valued function 'NODES' cannot have a column alias.
推荐答案
NODES
和 VALUE
需要小写 nodes
, 价值代码>.
NODES
and VALUE
needs to be lower case nodes
, value
.
这篇关于将 XML 参数传递给 SQL Server 存储过程时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!