Change Schema of all Tables in MS SQL

Ran across this little gem when needing to change the schema of all tables in a given database.

Obviously you’ll exchange “new_schema” with the schema of your choosing. From Ruslan Trifonov’s blog.

exec sp_MSforeachtable "ALTER SCHEMA new_schema TRANSFER ? PRINT '? modified' "

Leave a Reply

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