BUG: sp_dropuser Fails to Drop a User Who Is Also a dbo

Last reviewed: May 5, 1997
Article ID: Q93414

The information in this article applies to:
  • Microsoft SQL Server version 4.2a for OS/2
BUG# OS/2: 1467 (4.2)

SYMPTOMS

The system stored procedure sp_dropuser does not drop a user in the current database if the user's login happens to be a dbo in other databases, even if the user is only a regular user in the current database.

Consider the following scenarios:

Assume you have two databases A and B, and a login name Joe. Joe is a regular user in database A, named Joe_A. Joe is also a dbo in database B. When the dbo in database A tries to drop Joe_A using sp_dropuser, the following error from the stored procedure will result:

   You can't drop a database owner.

This is an incorrect behavior, because Joe_A is not a dbo in database A.

CAUSE

SQL Server incorrectly checks the conditions in the system stored procedure sp_dropuser. The code for this system procedure checks if the user to be dropped is a dbo using the following query:

   If exists (select * from sysdatabases
         where suid = @suid)
   begin
     print ("You can't drop a database owner")
     return(1)
   end

If the stored procedure were for dropping a login name, the above condition would be correct.

The correct condition should be:

   if @uid = 1
   begin
     print(......)
     return(1)
   end

WORKAROUND

Temporarily change the dbo in the other database to a different login name other than the user to be dropped.

STATUS

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


Additional query words:
Keywords : kbbug4.20a kbprg SSrvServer
Version : 4.2a
Platform : OS/2
Issue type : kberrmsg


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: May 5, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.