Help with labels

  • I am attempting to use the goto statement with a variable.

    I.E.

    CREATE PROCEDURE dbo.test

    @label VARCHAR(20)

    AS

    GOTO @label

    Step2:

    PRINT 'This is Step2'

    GO

    If @label was Step2 I want it to print This is Step2. Does anyone know how to do this? If you run this code it will report invalid syntax near @label. Any help would be appreciated. Thanks.

  • I'm afraid you can't use a variable in this manner

    Cheers,

    - Mark


    Cheers,
    - Mark

  • That's what I thought. I used IF statements instead. Thanks for your help.

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

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