Sunday, April 5, 2009

Need to change all the table schemas at one time? In my case, the default schema in the early run through DB design was the username (i.e. username.tablename)

Obviously, this has caused problems down the road.

Here's a fairly simple fix that will work in SQL Server 2005 or SQL Server 2008:
exec sp_MSforeachtable "ALTER SCHEMA newTableSchema TRANSFER ? PRINT '? modified' "

Hope it helps!


Post a Comment