August 19, 2010 at 11:13 am
FWIW, what's shown above is what some tools do.
Red Gate has SQLCompare, and it can easily script these changes and you could search/replace to all schemas.
Personally I'd build a script here, and loop over a list of schemas, altering my code each time to dynamically run this.
August 19, 2010 at 3:53 pm
You know, it will be a fairly large undertaking to setup all of the scripts, but after they are all setup you shouldn't have to touch them. Seems like just digging in and writing a script then copying it over and over again may be your best bet.
March 21, 2012 at 11:50 am
Hi,
I do have same requirement to move a table belongs to one schema(ex: dbo) to 30 other schemas.
I have used the alter statement given in this article.. But the table properties ,default values and primary keys were not being applied to new tables.
This is more useful incase of backup tables.
Is there any way to get create same table to multiple schemas with all the table properties (identity, primary key, default column values)..??
Thanks
Karnatakapu Mallikarjuna Rao
March 21, 2012 at 11:56 am
Hi,
I do have same requirement to move a table belongs to one schema(ex: dbo) to 30 other schemas.
I have used the alter statement given in this article.. But the table properties ,default values and primary keys were not being applied to new tables.
This is more useful incase of backup tables.
Is there any way to get create same table to multiple schemas with all the table properties (identity, primary key, default column values)..??
Thanks
Karnatakapu Mallikarjuna Rao
March 21, 2012 at 11:57 am
Hi,
I do have same requirement to move a table belongs to one schema(ex: dbo) to 30 other schemas.
I have used the alter statement given in this article.. But the table properties ,default values and primary keys were not being applied to new tables.
This is more useful incase of backup tables.
Is there any way to get create same table to multiple schemas with all the table properties (identity, primary key, default column values)..??
Thanks
Karnatakapu Mallikarjuna Rao
March 21, 2012 at 12:10 pm
Use the Generate Scripts option in Management Studio to script all your objects, including schema names. Use search-and-replace to replace the schema name with a different schema name, run the script. Repeat as needed. Then script your insert statements the same way, and run once on each schema.
Lots of work? Sure. Dumb idea? Probably. But maintaining 30+ schemas with the same tables is a bad idea, so solutions for how to do it are all going to be problematic. Honestly, whomever is requiring you to do this probably just doesn't understand what schemas are for.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 6 posts - 16 through 20 (of 20 total)
You must be logged in to reply to this topic. Login to reply