stored proc invocation does not return expected result...

  • Proc Code:

    Create proc myProc

    @tblname varchar(50)

    @myError int output

    As

    select @myError = 0

    begin try

    declare @sqlstring varchar(50)

    select @sqlString = 'select * from ' + @tblName

    exec (@sqlString)

    end try

    begin catch

    select @myError =1

    end catch

    Execution examples:

    Case 1. "table1 exists"

    declare @myError int

    exec dbo.myProc 'table1', @myError output

    print @myError

    Everything succeeds but no value is returnede for "@myError is printed (or it is empty?)

    Case 2: "table2 does not exist"

    declare @myError int

    exec dbo.myProc 'table2', @myError output

    print @myError

    This returns "1" as expected.

    Question: why did the first invocation not return "0" (i.e. @myError) as part of the result while the

    second proc performed as expected.

    TIA,

    barkingdog

  • Why should it error out? does the table not exist?

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

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