Friday 17 July 2009

Changing table schema

Sensible post today. Changing tables to a new schema >

To do for a given table -
ALTER SCHEMA [NewSchema] TRANSFER [tablename]


For all tables -
sp_MSforeachtable "PRINT '? modify'; ALTER SCHEMA [NewSchema] TRANSFER ?; IF @@ERROR = 0 PRINT '? modified'; PRINT ''"

No comments: