Stephen Daly - ASP.net/C# developer & technology enthusiast

SQL Server 2005 - Change the schema of all tables

I had a recent requirement to change the schema for all the tables in a SQL Server 2005 DB.

The following syntax changes the schema for all the tables in the database. You only need to change the "NewSchema" string with your new required schema name.

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

Have Fun!!


Posted by: Stephen
Posted on: 08/02/2008 at 3:47 PM
Tags: ,
Actions: E-mail | Digg it! | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (1) | Post RSSRSS comment feed

Comments

fez United States

Wednesday, June 10, 2009 10:53 PM

fez

THANK YOU!!!

I've tried about a half dozen different ways to do this today and this is the only one that worked.

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading