Change the table owner to dbo.

Source: Internet
Author: User
Change the table owner to dbo. When other users log on to the remote database, the new table owner is not dbo. To change the table owner to dbo, use the following statement to operate .www.2cto.com for batch modification: program code EXECsp_MSforeachtableexecsp_changeobjectowner ?, Dbo single modification: program code execsp_changeobjecto

Change the table owner to dbo. When other users log on to the remote database, the new table owner is not dbo. You can change the table owner to dbo using the following statements. www.2cto.com batch modification: program code EXEC sp_MSforeachtable exec sp_changeobjectowner ?, Dbo single modification: program code exec sp_changeobjecto


Change the table owner to dbo.

When other users log on to the remote database, the owner of the newly created table is not dbo. to change it to dbo, use the following words for Operation: www.2cto.com

Batch modification:

Program code EXEC sp_MSforeachtable 'exec sp_changeobjectowner ''? '', ''Dbo '''

Single modification:

Program code exec sp_changeobjectowner 'name of the table to be changed ', 'dbo'

Manual modification:

Click "table"> "design"> "properties"> "change the owner. This method is applicable when the number of tables is small.

Www.2cto.com

-- If a database (table and stored procedure) has multiple user names, you can use the following statement to change all of them to dbo:

Select 'SP _ changeobjectowner ''' + User_Name (Uid) + '. '+ name + ''', ''dbo'' From sysobjects Where Uid Not in (User_ID ('dbo') And Type In ('U', 'P ')

-- Then copy the query statements and change the objects in the table and stored procedure when running them directly. However, SQL SERVER must exit and then go in, to see the changed result.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.