INSERT using LIST into Stored Procedure

后端 未结 2 1240
不知归路
不知归路 2020-12-18 16:17

I have this stored procedure:

CREATE PROCEDURE [RSLinxMonitoring].[InsertFeatures] 
   @Features nvarchar(50), 
   @TotalLicenses int, 
   @LicensesUsed int,         


        
2条回答
  •  青春惊慌失措
    2020-12-18 16:47

    If you are using SQL server 2008 & above, you can use below solution. Declare Table type like :

    CREATE TYPE FeatureServerType AS TABLE 
    (
       [Features] nvarchar(50)
       ,[TotalLicenses] int
       ,[LicensesUsed] int
       ,[Server] nvarchar(50) 
    );
    

    Use it like :

    CREATE PROCEDURE [RSLinxMonitoring].[InsertFeatures] 
       @TabletypeFeatures FeatureServerType READONLY
    AS
       SET NOCOUNT ON;
    
       INSERT INTO [RSLinxMonitoring].[FeatureServer]
            ([Features]
               ,[TotalLicenses]
               ,[LicensesUsed]
            ,[Server])
       SELECT * FROM @TabletypeFeatures 
    

提交回复
热议问题