error 15284 when trying to drop user

  • I'm trying to drop a user and am getting 'The database principal has granted or denied permissions to objects in the database and cannot be dropped. (Microsoft SQL Server, Error: 15284)'

    I did

    select user_name(grantor), object_name(id), *

    from sysprotects (nolock)

    where grantor = USER_ID ( 'the_user' )

    to see what the object is, but object_name(id) is NULL

    any ideas on the next move?

    thanks

  • this is the query i use for defining object ownership:

    ;with objects_cte as

    (

    select

    o.name,

    o.type_desc,

    case

    when o.principal_id is null then s.principal_id

    else o.principal_id

    end as principal_id

    from sys.objects o

    inner join sys.schemas s

    on o.schema_id = s.schema_id

    where o.is_ms_shipped = 0

    and o.type in ('U', 'FN', 'FS', 'FT', 'IF', 'P', 'PC', 'TA', 'TF', 'TR', 'V')

    )

    select

    cte.name,

    cte.type_desc,

    dp.name

    from objects_cte cte

    inner join sys.database_principals dp

    on cte.principal_id = dp.principal_id

    WHERE dp.name <> 'dbo'

    order by dp.name

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Did you tried querying sys.database_permissions?

    select * from sys.database_permissions where grantor_principal_id = user_id ('USERNAME')

  • thanks, but the user in question was not returned as an owner

    I should also mention that the user is an orphan (that is, there is no associated login) - not sure if that is relevant or not

  • and

    select *, object_name(major_id) from sys.database_permissions where grantor_principal_id = user_id ('the_user')

    returned NULL for object_name(major_id)

Viewing 5 posts - 1 through 4 (of 4 total)

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