Help Passing Table Name as Stored Proc Parameter

  • I created the following Stored Procedure however when I try to Exec and pass a value for the table name it says Invalid Object Name '@CheckTable'

    Msg 208, Level 16, State 1, Procedure Invalid object name '@CheckTable'.

    Exec sp_vcGetStop 'CHECKS_DEC2007','3300000001'

    CREATE PROCEDURE [dbo].[sp_vcGetStop]

    @CheckTablevarchar(15),

    @Sequence numeric(10,0)

    AS

    BEGIN

    SELECT CUID As 'Rt', WorkType

    FROM [@CheckTable]

    WHERE Sequence = @Sequence

    END

  • It doesn't work like that. Google "dynamic sql" and sp_executesql or look it up in BOL.

    There is no "i" in team, but idiot has two.
  • Thanks issue resolved.

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

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