I ran into a situation today where I needed to alter all tables for an MS SQL Server 2005 database.
A quick Google revealed this post from Ruslan Trifonov.
exec sp_MSforeachtable "ALTER SCHEMA new_schema TRANSFER ? PRINT '? modified' "
Excellent :-) That was easy ...
Reference to ALTER SCHEMA command is here.
In it's simplest form, the command appears to take this shape: ALTER SCHEMA HumanResources TRANSFER Person.Address;
For those who aren't familiar with the '?' in T/SQL, it's represents a parameter, so this statement is parameterized. Essentially, sp_MSforeachtable is going to pass the name of each table to statement/query.
Great stuff. Big thanks to Ruslan. That was easy :-)
Subscribe to:
Post Comments (Atom)
The Database is not accessible after creating Always On Availability Group
Having created a fully functional SQL Server Always On Availability Group, I connect using SSMS. Upon trying to expand the database, I get ...
-
Most of what we're going to want to look at when you're having production issues are available through DMV's. If granti...
-
BibleGateway.com - Passage Lookup: John 10:7, 9-10 9I am the gate; whoever enters through me will be saved.[a] He will come in and go out, a...
-
I was not able to find what I considered a good, clear reference for this when I recently encountered it at a customer installation. I fou...
No comments:
Post a Comment