SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[ModifyChangeInfo] @ScreenSetRecordID int, @ScreenSetRecordID AS declare @GroupIndex, @Group_ID begin //已经查找出了@GroupCount 就是ScreenSetGroups中<ID>节点的个数 for(@GroupIndex=0;@GroupIndex<@GroupCount;@GroupIndex++) begin select @Group_ID=ScreenSetGroups.value('(/Groups/ID)[@GroupIndex]','int') from dbo.ProgramMenuScreenSet_Casual where ScreenSetRecordID=@ScreenSetRecordID end end 像这样的句子行吗 特别是@Group_ID=ScreenSetGroups.value('(/Groups/ID)[@GroupIndex]','int')我想用这个循环找xml字段中的节点(ScreenSetGroups的类型是“<Groups><ID>111</ID><ID>222</ID>```</Groups>”这样的) 这个样子行吗 是不是(/Groups/ID)[@GroupIndex] 这样是不行的?
因为报错信息不一定是准确的。 运行时错误基本都不准
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[ModifyChangeInfo]
@ScreenSetRecordID int,
@ScreenSetRecordID
AS
declare
@GroupIndex,
@Group_ID
begin
//已经查找出了@GroupCount 就是ScreenSetGroups中<ID>节点的个数
for(@GroupIndex=0;@GroupIndex<@GroupCount;@GroupIndex++)
begin
select @Group_ID=ScreenSetGroups.value('(/Groups/ID)[@GroupIndex]','int') from dbo.ProgramMenuScreenSet_Casual
where ScreenSetRecordID=@ScreenSetRecordID
end
end
像这样的句子行吗 特别是@Group_ID=ScreenSetGroups.value('(/Groups/ID)[@GroupIndex]','int')我想用这个循环找xml字段中的节点(ScreenSetGroups的类型是“<Groups><ID>111</ID><ID>222</ID>```</Groups>”这样的) 这个样子行吗 是不是(/Groups/ID)[@GroupIndex] 这样是不行的?