How to pass Table as an argument in Function or Stored Procedure

  • hi,

    i m able to return a TABLE thru Function.

    Now, i need to pass TABLE as an argument to a Function or Stored procedure.

    How would i manipulate it in the function/stored proc.

    OR is it possible to pass different arguments in the same Function/Stored Procedure.

    thnx.

  • You can't do that, AFAIK.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • OK

    Any other method which i can use for the multiple arguments...

    Thru XML ????

    i need to create a STORED PROC which will convert its arguments into INSERT's, UPDATES, DELETES...

    The arguments are not certain...

  • Sounds like dynamic sql task here... What problem are you trying to solve?

  • Frank is right of course, you cannot do this. However, when presented with this problem, I have used the following solution in the past. First create a table with all of the fields that you wanted to pass into the stored procedure and then add one more field (I called mine the TokenId). Add all of the data that you want passed into the procedure with the same TokenId. Have the stored procedure have an input parameter with that same TokenId. The procedure can then query the table retrieve the data and when it is finished processing the data it can be deleted from this table by the procedure. This lets you have multiple version of this procedure running at the same time without the table getting to large.

  • Maybe you get some additional ideas here: http://www.sommarskog.se/share_data.html

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • I often do this by sending my data in as a delimited list, eg with commas etc.

    Then I have a UDF that is called SplitString, which returns a table from the string.

     

    Martin

  • i m also doing the same thing...

    thnx...

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply