zoukankan      html  css  js  c++  java
  • sqlserver2008 存储过程使用表参数

    ----首先,我们定义一个表值参数类型,其实就是一个表变量  
    Create type dbo.tp_Demo_MultiRowsInsert as Table  
    (  
    [PName] [Nvarchar](20) NOT NULL,  
    [GName] [Nvarchar](20) NOT NULL  
    )  
    GO  
      
    ----下面我们用这个表变量做参数,通过存储过程调用它  
    CREATE Procedure dbo.CPP_InsertMultiRows  
    (@ManyRows as tp_Demo_MultiRowsInsert readonly  
    )  
    as  
    INSERT [dbo].[tb_Demo_MultiRowsInsert]  
    SELECT PName,GName from @ManyRows  
      
    GO  
      
    ----程序中构造多个行集  
    DECLARE @tmpRows as tp_Demo_MultiRowsInsert  
      
    ----插入多个数据到参数表中  
    INSERT @tmpRows(PName,GName) values('胡一刀','国土资源部')  
    INSERT @tmpRows(PName,GName) values('胡青牛','医药局')  
    INSERT @tmpRows(PName,GName) values('令狐冲','文广中心')  
      
    ----传递参数到存储过程,完成一次多行集插入  
    EXEC dbo.CPP_InsertMultiRows @tmpRows
  • 相关阅读:
    Spring restful
    LDAP & Implementation
    Restful levels and Hateoas
    事务隔离的级别
    servlet injection analysis
    session and cookie
    write RE validation
    hello2 source analysis
    匿名函数和递归函数
    生成器和迭代器,列表推导式
  • 原文地址:https://www.cnblogs.com/lrl45/p/5135438.html
Copyright © 2011-2022 走看看