table data type in stored procedures

  • Hello,

    Is there anyone who can tell me if there is a way to declare a table type variable in stored procedures?

    I’ve tried this:

    create procedure sp1

    (@table1 table (a1 int, a2 int))

    as

    select * from @table1

    go

    And I get the following error:

    Server: Msg 156, Level 15, State 1, Procedure sp1, Line 2

    Incorrect syntax near the keyword 'table'.

    Server: Msg 137, Level 15, State 1, Procedure sp1, Line 5

    Must declare the variable '@table1'.

    From Books OnLine:

    table variables can be used in functions, stored procedures, and batches.

    Edited by - adosun on 10/08/2003 02:41:49 AM

    Edited by - adosun on 10/08/2003 02:46:07 AM

  • They can be used in SP's but don't think they can be used as parameters.

    You have to delcare them within the body of the SP...

    DECLARE @table1 table (a1 int, a2 int)

    Dan

Viewing 2 posts - 1 through 1 (of 1 total)

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