Peter Larsson Blog

Patron Saint of Lost Yaks

Change schema for all tables

I just helped a guy here with schema
and thought that someone could benefit from this code




sp_MSforeachtable "PRINT '? modify'; ALTER SCHEMA new_schema TRANSFER ?; IF @@ERROR = 0 PRINT '? modified'; PRINT ''"

Legacy Comments

re: Change schema for all tables
This little piece of code has helped me so many times! Thanks for sharing!