One of the ways that I measure the maturity of an organization it it's ability to handle change with a minimum amount of pain, and one good example is moving databases. It's not every day you need to move a database, but it's not uncommon either - sometimes because you need more space, need to reduce the load on the server, move the database to a server with more power, or maybe just migrate from that old NT4 box in the corner of the server room. So how prepared are you to move a database, right now?
--three part syntax, we're in the Corp database, if we move we have to either have the Adventureworks database, or change the reference Select * from Adventureworks.person.contact where lastname='smith'
--four part syntax, getting data from another server, this will work fine as long as the new server has a linked server called SERVER12 pointing to the correct server. select * from Server12.Adventureworks.person.contact
The right way to handle this it to require two part syntax everywhere, using either views or synonyms to provide the needed abstraction. For example, in our three part syntax example above we just do this:
create view vAdventureWorksPersonContact as select * from AdventureWorks.person.contact Which changes our code to: Select * from dbo.vAdventureWorksPersonContact where lastname = 'smith' Synonyms go a step deeper in that you can use them for stored procedures and functions in addition to tables. Regardless of technique, but abtracting those external references you know that you only have to change them, no further looking is needed if...if... you've applied a stern hand as changes are deployed!
create view vAdventureWorksPersonContact as
select * from AdventureWorks.person.contact
Which changes our code to:
Select * from dbo.vAdventureWorksPersonContact where lastname = 'smith'
Synonyms go a step deeper in that you can use them for stored procedures and functions in addition to tables. Regardless of technique, but abtracting those external references you know that you only have to change them, no further looking is needed if...if... you've applied a stern hand as changes are deployed!
I'm sure there are other steps I haven't listed, but you can see that moving is not trivial. In fact, it's often risky enough that it makes sense to add space/memory/CPU capacity to the box to avoid the move, or to replace the entire server to accomplish the same. But at the same time I hope you'll realize that as a DBA you can do a lot to make those moves go faster and with less risk if you think about the problem now and put some good policies in place, especially for steps 4, 5, 6, and 7.
I blog at http://blogs.sqlservercentral.com/blogs/andy_warren/default.aspx about SQLServer, SQL user groups, and related topics. I hope you'll visit and comment occasionally!
To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.
We ask you to register on the site and subscribe to our newsletters. Subscribing to our newsletters gets you:
We ask that you give the newsletter a try for a week. Over 200,000 SQL Server Professionals a day find it entertaining and useful. If not, you are welcome to unsubscribe at anytime.
Steve Jones Editor, SQLServerCentral.com