Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 change table owner

Author  Topic 

tokue
Starting Member

16 Posts

Posted - 2012-04-09 : 10:00:28
Hi,

Can we change a table owner using sql?
Second question: What is the meaning of (dbo)? I noticed that all tables in my database have (dbo) as the owner?

another question (please forgive me
I noticed after converting my 2005 database to 2008 that the new database is almost one third of the old one in size (was 90 mbyte, 36 mbyte after converting it). why did that happen? and is there a way to clean or shrink the old database using a sql statement.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-04-09 : 10:38:17
This is from Books On Line

The following example modifies the schema HumanResources by transferring the table Address from schema Person into the schema.

USE AdventureWorks;
GO
ALTER SCHEMA HumanResources TRANSFER Person.Address;
GO


Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

tokue
Starting Member

16 Posts

Posted - 2012-04-09 : 11:14:58
I don't understand your code jimf. can you explain it please.
Thanks to google I succeeded in changing the owner (OLDOWNER) of my table (TB) using this query:
exec sp_changeobjectowner 'OLDOWNER.TB', 'dbo'

still waiting for answer about shrinking the database!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-04-09 : 11:20:25
dbo means database owner. its the default schema available within sql server

http://www.sqlteam.com/article/understanding-the-difference-between-owners-and-schemas-in-sql-server

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-04-09 : 11:23:56
you can use DBCC SHRINKDATABASE for shrinking a db

http://msdn.microsoft.com/en-us/library/ms190488.aspx

for shrinking a individual file use DBCC SHRINKFILE
http://msdn.microsoft.com/en-us/library/ms189493.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -