Locked resource message

  • Anyone ever experience this?

    We were implementing some new code this weekend and kept getting a locekd resource message in one procedure. We went as far as stopping SQL to release the lock but no luck.

    What it turned out to be was a temp tables was being loaded (simple insert) from a remote table. The tables had the same elements BUT they were not in the same order. There was no column list used in the insert, obviously.

    Talk about fun to troubleshoot!

    Speaking of bad code, we ran across someone's procedure call that does somethng we've never seen:

    exec sproc @a = @a, @b-2 = @b-2, @c = @c

    Is there any reason for assigning a variable to itself in an exec statement?

  • "exec sproc @a = @a, @b-2 = @b-2, @c = @c

    Is there any reason for assigning a variable to itself in an exec statement?"

    This is actually not assigning a variable value to itself, instead it is associating the local variable with the "named" variable as defined in the stored procedure:

    CREATE PROC sproc (@a int, @b-2 int, @c int)

    This is mainly so you can specify the parameters out of definition order like:

    EXEC sproc @c = @c, @a = @a, @b-2 = @b-2

    Look in BOL for the system stored procedures and CREATE PROC for more into.

    Andy

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

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