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
 General SQL Server Forums
 New to SQL Server Administration
 Using sp_changeobjectowner in SQL2008

Author  Topic 

waveform
Yak Posting Veteran

93 Posts

Posted - 2011-12-06 : 07:18:15
Hi, in SQL2000, I was able to change the owner of a table by doing the following:

sp_changeobjectowner [dbo.my_table_name], [my_db_user_name]

However in SQL2008, trying to do the same thing, it comes up with the error:
quote:
Database principal or schema 'my_db_user_name' does not exist in this database

However it does exist, as my application logs in with it. I'm attempting to change the owner from "dbo" to my user name, before uploading the database to my web host.

Is there some kind of prefix or something I need to use when specifying the new owner in SQL2008?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-06 : 07:38:18
whats the schema the user is mapped to in sql 2008?

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

Go to Top of Page

waveform
Yak Posting Veteran

93 Posts

Posted - 2011-12-06 : 08:53:23
Sorry, how do I find that out in SSMS? :)
(I still prefer the old SQL Enterprise Manager..so much easier to use!)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-06 : 10:44:17
comes under your database->security->schemas in ssms

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

Go to Top of Page

waveform
Yak Posting Veteran

93 Posts

Posted - 2011-12-06 : 11:13:12
Ah, I see, thanks. The user is called "nhat1_user1", and is listed as owner of db_datareader and db_datawriter. I have just assigned it to db_owner as well, but still can't run the command.

It's saying the "principal or schema 'nhat1_user1' does not exist in this database."
The actual command I'm typing is:
sp_changeobjectowner [dbo.id_job],nhat1_user1

"id_Job" is the table I want to change ownership of, from "dbo" to the user.


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-06 : 12:20:21
i hope you're not using wrong name like you did here

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=168709

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

Go to Top of Page

waveform
Yak Posting Veteran

93 Posts

Posted - 2011-12-06 : 12:34:16
Thanks for reminding me. :p Nope, username is definitely "nhat1_user1".
I gather you're saying it should work?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-06 : 12:50:25
quote:
Originally posted by waveform

Thanks for reminding me. :p Nope, username is definitely "nhat1_user1".
I gather you're saying it should work?


it should work if such a schema exists but error messages suggests otherwise!

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

Go to Top of Page

waveform
Yak Posting Veteran

93 Posts

Posted - 2011-12-07 : 00:46:10
Ok, I'm sure this will convince. :)

User details dialog:
http://i.imgur.com/8lo1K.gif

SQL statement and error:
http://i.imgur.com/hHqHc.gif

Hopefully you can see something I'm doing wrong there, because it's a puzzle to me.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-07 : 00:56:45
sorry cant view images from here as its blocked
I will take a look later in day from home and see

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

Go to Top of Page

waveform
Yak Posting Veteran

93 Posts

Posted - 2011-12-07 : 01:44:59
No worries. Thanks very much for your time.
Go to Top of Page
   

- Advertisement -