SQL Server 2008 – Change multiple Table Schemas at once

by Joseph on Apr 6th in SQL Server, SQL Server 2005, SQL Server 2008, Table Schema

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!

Leave a Reply


Warning: Undefined variable $user_ID in H:\root\home\idriven-001\www\infocraftnet\wp-content\themes\worldoweb\comments.php on line 55

Powered By Wordpress Designed By Ridgey