BUG: Stored Procedure Holds EX_lock on a Table

Last reviewed: April 29, 1997
Article ID: Q115245

The information in this article applies to:

  - Microsoft SQL Server version 4.2
BUG# NT: 789 (4.2)

SYMPTOMS

Executing a stored procedure that depends on a table which has been dropped and recreated after the creation of the SP will cause the following error:

   Msg 229, Level 14, State 1
   DELETE permission denied on object <table name>, database <db_name>,
   owner dbo
   Msg 229, Level 14, State 1
   DELETE permission denied on object <table name>, database <db_name>,
   owner dbo

Also, an exclusive lock will be retained on the table until another SQL command is executed by the process.

For example:

Login as sa (dbo of pubs)

   - Create a sample table in the pubs db:
        create table test (c int)
   - Create a sample sp in the master db:
        create proc u_sp_test as delete from pubs..test
   - Grant execute on u_sp_test to public
   - Drop and recreate the table test
   - Create a login id 'testuser'

Login as testuser

   - Execute 'u_sp_test'

Msg 229, Level 14, State 1 DELETE permission denied on object test, database pubs, owner dbo Msg 229, Level 14, State 1 DELETE permission denied on object test, database pubs, owner dbo

>From another process execute sp_lock

spid     locktype               table_id        page      dbname
------   --------------------   -----------     -----     -------------
3        Sh_intent              496004798       0         master
3        Ex_extent              0               128       tempdb
4        Ex_table               688005482       0         pubs

WORKAROUND

Drop and recreate the stored procedure in question.

STATUS

Microsoft has confirmed this to be a problem in Microsoft SQL Server version 4.2. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


Additional query words: sysdepends sysprocedures Windows NT
Keywords : kbbug4.20 kbprg SSrvStProc SSrvWinNT
Version : 4.2 4.21
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.