473,390 Members | 1,131 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

T-Sql for changing the Owner of the table objects in a database

I have a MS SQL Server Database which consists of several Tables, amongh some has owner as "dbo" and some has another owner like "xyz".
Is there any T-SQL that can change the owner [xyz] of the tables to "dbo".

And plz clarify the fact how a owner can be determined at the time of table creation.
Feb 6 '07 #1
3 16544
1,017 Expert 512MB
To change owner

EXEC sp_changeobjectowner 'table_name', 'dbo'

To create table or any database object with dbo owner you have to mention it in create statement otherwise it is your UID.

[PHP]Create table dbo.table_name ( column1 datatype1, .... )[/PHP]

I think it depends on Server settings in some cases dbo is a default owner.
Feb 6 '07 #2
168 Expert 100+
I think it depends on Server settings in some cases dbo is a default owner.
It depends on current user, so if user that executes the create statement is dbo in the database, then objects by default would be created under dbo
Feb 6 '07 #3

You can change object owner in a streatch with the following command if you are having more no of tables to change object owner.

select 'execute sp_changeobjectowner '+ '''' + 'xyz.'+name+''''+','+'''dbo''' from sysobjects where xtype = 'U' and uid=5 order by name
Feb 15 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

by: geoff | last post by:
I'm trying to create a new database and new login to allow a client (through my asp.net page) to create their own database, username and password. I've tried using the stored procedures I've found...
by: Cornelio Royer | last post by:
how can i to hide the owner table, if i connect using odbc.... thanks... -- CORNELIO ROYER WIN SOFT CORP., S.A. OFICINA (507) 264 4376 CELULAR (507) 674 1218
by: pw | last post by:
Hello, I used a user to create a database but postgreSQL insists that the 'postgres' user is the owner. It's a bit annoying to have to change users to link sequences to counter values. How...
by: bb nicole | last post by:
Below is my interface for resume which need to post into database... I have did it all in one page and it already can send into database which the table name resume... But my letturer now want me...
by: Serman D. | last post by:
Hi all, How do I describe non-table objects, like UDF functions and procedures, using db2's normal command line interface? Database server = DB2/LINUX 9.1.0 Express-C running on Linux 2.6...
by: ceejee | last post by:
hello there! especially to those experts here in this forum. glad to be here. this is my first post here and sorry if its a problem. later i will try to answer also those questions where i have...
by: EgoSum | last post by:
I make dataset in c# and after that add the column into table in database. Although I expand dataset with it, app dont recognize added column. It's haped to me several times. What can I do to...
by: nafi925 | last post by:
hi all i need some help on my project' i need to get xml string of a table from database to send mail's am currently using a STORED PROCEDURE but am returning a nvarchar(max) value so the length...
by: alisyah | last post by:
is it possible to insert the time table in database?
by: atoy | last post by:
Good day, When i create a new blank database, when i go in the user group and permissions and then i click on change owner tab. I notice that the user Admin is always the current owner of the...
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.