• If you want to use a table for a stored procedure, you can create a function which will return a table and then use this function in your stored procedure. Something like this

    CREATE FUNCTION dbo.fnFunction_Name

    (

    @Param1 VARCHAR(8000),

    @Param2 VARCHAR(8000)

    )

    RETURNS @Results TABLE (intRowId INTEGER IDENTITY(1,1) , Items VARCHAR(8000))

    AS

    BEGIN

    //Your body here.

    //You can insert the resultset in the table variable @Results in the body.

    //At the end do not forget to return the variable

    Return

    END

    You can use this function directly as a table i.e.

    SELECT * FROM dbo.fnFunction_Name(@Param1, @Param2)

    I hope this will be of some help to you.