Superlative Solutions' HelpDesk Language
 
Home Knowledge Base ColdFusion and Programming SQL Server change of object ownership
Information
Article ID9
Created On3/15/2008
Modified3/15/2008
SQL Server change of object ownership

Description of Issue
It is very common that a user will create objects in SQL Server WITHOUT specifying the [dbo]. prefix (for example, when creating a table). This causes a significant problem when moving the database to another server and/or provider because the object may link to a non-existent user.

Additionally, the object ownername will either need to be specified in queries OR the connection to the server must be made using the object's owner name. This is generally not desirable.

SQL Server will use the object owned by the special 'dbo' account of an object does not exist with the logged in user's name. This is the preferred method.

Resolution
In the event a user does create objects without the dbo ownership, the following script can be ran to correct this problem. You may download the script by clicking on the download in the links section.

NOTE: You must make sure to update the @OldUser variable to the object owner name you wish to change to dbo.

Download the SQL Script
The following links may provide helpful information concerning this issue (Superlative Solutions is not responsible for the content on the referenced site and does not guarantee any links remain valid):

download Download the SQL Code