Re: drop a database user. assign objects to dbo.



light_wt (lightwt@xxxxxxxxxxxxxxxxxxxxxxxxx) writes:
we are on sql2005.

your explanation is great, but, a bit over my head. can you point me to
some detail step-by-step doing it using SSMS?

Should all objects in the database be owned by dbo?

I would expect that they really are, because you would not be able to
drop his user, if he owned objects.

You can find objects that are not owned by dbo with this select:

SELECT s.name + '.' + o.name, owner = dp.name
FROM sys.schemas s
JOIN sys.objects o ON s.schema_id = o.schema_id
JOIN sys.database_principals dp ON o.principal_id = dp.principal_id
WHERE o.principal_id <> 1

You can use this command

ALTER AUTHORIZATION ON object TO dbo

If there are loads of objects, you could use the SELECT above to generate
the commands.

--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.



Relevant Pages

  • Re: Massive Log Files
    ... command with the TRUNCATE_ONLY option, you can find more info in books ... Co-Author SQL Server 2000 Programming by Example ... > We have a problem with huge log files for our SQL Server databases. ... > We've been digging through Books Online and trying various esoteric ...
    (microsoft.public.sqlserver.tools)
  • Re: database optimization
    ... Isn't there a single command that will take care of the whole database ... certain fragmentation level. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: On to Bulk Insert issues
    ... in what situations does the sql server 2000 return with such an error? ... there is an error with your delimiters, so that BCP gets out of sync. ... post the CREATE TABLE command for the table and the ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: 100 % CPU Usage
    ... > the sp_who2 command. ... there is a lot of CPU on the Lazy Writer given the login time. ... If this indeed is a bug in SQL Server, ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Why would adding dbo. cause my function to run forever?
    ... As soon as i remove the dbo. ... owners, and you are logged in as that owner when you try this? ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)