?
Solved

Change owner of a view

Posted on 2004-11-30
6
Medium Priority
?
325 Views
Last Modified: 2012-05-05
I have lots of VIEWs that I have created in my DB. It turns out that one VIEW took my NT user as the owner of the VIEW. normally its dbo. i need the owner to be dbo so I can make changes to it because at the moment it gives me an error saying that the object name (the views name) is invalid.
thanks
cm
0
Comment
Question by:carlosmonte
  • 3
  • 3
6 Comments
 
LVL 16

Expert Comment

by:muzzy2003
ID: 12707424
EXEC sp_changeobjectowner 'view name', 'dbo'
0
 
LVL 1

Author Comment

by:carlosmonte
ID: 12707445
Where do I run this command, I only use eterprise manager and am kinda new on db
0
 
LVL 16

Accepted Solution

by:
muzzy2003 earned 500 total points
ID: 12707510
You need to run it in SQL Query Analyser. It's in the Tools menu in EM. Log on, then select the appropriate database from the dropdown at the top of the window. Paste this code into the window, and hit F5 to run it.
0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
LVL 1

Author Comment

by:carlosmonte
ID: 12707559
great, thanks
0
 
LVL 1

Author Comment

by:carlosmonte
ID: 12707637
Could you tell me how it came to get to be owned by my user when normally its owner is just dbo when i've create others?
0
 
LVL 16

Expert Comment

by:muzzy2003
ID: 12707961
It's owned by whoever you're authenticated as when you create it. If that user is a member of the dbo role, then I think it should be assigned to dbo as owner. If not, for whatever reason, it will be assigned to the NT or SQL login that you are using. Since you do this via EM, I am slightly perplexed, as you are likely always to authenticate in the same way. Could someone else have been playing with the database at the same time, or do you have exclusive use of it. They could have been tinkering with role memberships.
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question