• Sure, I run it in the correct database!

    SQLSACT (5/5/2013)


    zhazhuzhao (5/5/2013)


    SQLSACT (5/3/2013)


    Can't remember where I found it, use this script to determine which objects are owned by the user

    ;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 = 'user_name'

    Use this script to change the owner to dbo

    alter authorization on object_name to dbo

    Hi, I tried this sql and it returns no data! Also this database user is not a db_owner user!

    Thanks all the same!

    Silly question - Are you executing the script against the correct database?