array in procedure



  • Establishing a procedure like:

    CREATE PROCEDURE func
        @tmp  INTEGER,
        @lot INTEGER,
        @qty  INTEGER
    AS
    

    To transfer something like:

    EXEC func
        @tmp = 77,
        @lot = 191,
        @qty = 102;
    

    But how do you make it possible to transmit many values to an arbitrary long (bundle)? For example:

    EXEC func
        @tmp = 77,
        @lot = 191, 201, 199, 63,
        @qty = 102, 314, 271;
    


  • If the version of the version of the server 2008 and can be used https://msdn.microsoft.com/ru-ru/library/bb510489(v=sql.100).aspx :

    CREATE TYPE intTable AS TABLE (value int)
    GO
    CREATE PROCEDURE func
        @tmp intTable READONLY,
        @lot intTable READONLY,
        @qty intTable READONLY
    AS 
    BEGIN
       ...
    END;
    GO
    DECLARE @t intTable, @l intTable, @q intTable;
    INSERT @t (value) VALUES (77);
    INSERT @l (value) VALUES (191), (201), (199), (63);
    INSERT @q (value) VALUES (102), (341), (271);
    

    EXEC func @tmp = @t, @lot = @l, @qty = @q




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2