存储过程间XML参数传递的实例

情到浓时终转凉″ 提交于 2020-03-03 18:33:40

--测试数据准备
Create table Product (ProductID varchar(18),cName varchar(50))
insert into Product Select '80100212800','A'
insert into Product Select '80100250006','B'
insert into Product Select '80101038000','C'
-- 测试执行    
 Exec ProductGet
 
 
--- 第一层代码
Alter PROCEDURE ProductGet
AS
Begin
 Declare @sql as nvarchar(max)
 Declare @cXML as XML
 Declare @cXML1 as XML
 Declare @cXML2 as XML
 Declare @cXML3 as XML
 
    Exec ProductOne '80100212800',@cXML1 Out
    Exec ProductOne '80100250006',@cXML2 Out
    Exec ProductOne '80101038000',@cXML3 Out
    --Set @cXML1 = @cXML1 + @cXML2 + @cXML3

 
   Declare @cXML_ as XML
  Set @cXML_ = (Select DISTINCT  * From (
             SELECT
            x.item.value('@OrderID[1]', 'VARCHAR(20)') AS OrderID,
            x.item.value('@ProductID[1]', 'VARCHAR(20)') AS ProductID
      

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!