• This is a guess based on the Truncate example.

    Your Cursor is based on the same table that is being updated in the INSERT and Update statements. The Cursor is holding a lock on that table. Try Declaring your Cursor as READ_ONLY.

    Also, instead of:

    INSERT INTO Table1(obj_name, Obj_type)

    EXEC (@SQL)

    UPDATE Table1 Set ...

    You could put the @dbName and @tableName in the SQL Statement and do it as one statement.

    Even Better: Find a way to do this without a cursor. There doesn't seem to be anything in there that requires working on one row at a time.

    --

    JimFive