Alter Schema Owner at Tables, Views and Stored Procedures

Here is a quick and easy way to alter the schema of any of the objects in your sql server that has been created with any other user than the dbo. This has been giving me troubles when using TSQL and has been difficult to change it using the sql managment studio.

SELECT 'ALTER SCHEMA dbo TRANSFER ' + SCHEMA_NAME(schema_id) + '.' + name
FROM sys.tables
WHERE schema_id != SCHEMA_ID('dbo');

2 Comments

  1. Yes, that’s it! It worked properly for me. Great!

  2. Hi my friend! I wish to say that this post is amazing, nice written and include approximately all significant infos. I would like to see extra posts like this.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.