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

--测试数据准备
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
      

猜你喜欢

转载自blog.csdn.net/moqing/article/details/104634490
今日推荐