Table variable

  • How can I pass a table variable as a parameter to a stored procedure ?

    eg.

    create proc procname ( @param table (col1 int ) )

    as

    select .....

    I get the following error :

    Server: Msg 156, Level 15, State 1, Procedure procname, Line 1

    Incorrect syntax near the keyword 'table'.

    Is there any alternate way to do this ?

    Thanks.

  • We cannot pass a table variable to a stored procedure. The alternate way I used is to create a temp table and delete the data at the end of the proc.

  • While backing up my laptop, I read a VERy interesting article in the latest edition of SQL Server Mag. InstantDocID 40404.

    In short it says, you should prefer the use of temp tables over table variables (especially on large resultsets) for 'big performance' gain.

    Frank

    http://www.insidesql.de

    http://www.familienzirkus.de

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

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

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