Monday, September 15, 2014

Maps database user 'dbo' to a server login instead of sa

Once upon a time, when human being was so naive and innocent, everyone wrote their application starting with the statement:

"It needs to connect to the database as the 'dbo' database user, or the application would not work at all."

That was the golden rule of thumb in software development. Years and eras gone by and a bunch of developers keep telling the whole world that it is necessary to stay that way, or the application would not work at all. Full stop.... The bunch of developers said.

Let's face the now-a-day facts:

  1. Human being is not so naive and innocent now-a-day. We couldn't trust people like how it was used to be.
  2. There are ways for how applications connect to the database, other than solely connecting as the 'dbo' database user.
  3. Based on point 1, the world is asking for more to be done to keep their data secure.
  4. Based on point 2, if one could not code without solely connecting as the user 'dbo', it is more likely an issue with capability or indolence.
  5. Based on point 1 & 2, the argument that "an application required to be the DBO user and the database owners" is simply invalid.

Given there are now-a-day facts, there are still out-dated people thus applications. In our case, we have limited choices for a number of reason to stuck with a suboptimal application. At certain point, you can only work with it.

As a DBA, one would usually find that this happens when a database needs to be migrated from an old SQL Server 2000 instance to a newer version on SQL server. Once you restore the database and found that the database owner was empty, in general a DBA will assign the database ownership to 'SA' and then create a database user for the App's service account - here is the point that when the application vendor would told you that it is not 'correctly' set up.

What you can do to compromise the database to comply with their so called system requirement? The following command would help you to associate a server login to the database dbo user:

Thursday, September 04, 2014

Tracing Deprecated Features SQL Server during database migration or upgrade

Imagine. You have an in-house developed application which you spent so much time and effort on to enable it to close to perfection. Users love you for the state of art build and you feel you have achieved something to be proud of.

2 years down the track, it is time for SQL server major upgrade. Let's bump it up a version and take advantage of the new features and enhancement that Microsoft charge you for. After that hard work on SQL server upgrade, you found that you great perfect application - shows some show stopper issue. You know, it is kind of frustrating if you have developed a database object and one day it just stops working because Microsoft decide to make the world better by retiring existing build-in object and function and replace with a better new one.

Users are asking why your perfect application doesn't work, and suggesting that let's abandon the upgrade project as everything is working at the moment, why change? (the usual normal people...). Time is clicking and you are stress....

I don't want to be there, at that timing. So let's be proactive!! You can found out what deprecated function your application is currently using and how frequent that they are being use with the following query:

And this is a list of link from Microsoft to show you what is required to look out:

Deprecated Database Engine Features in SQL Server 2008 R2

Discontinued Database Engine Functionality in SQL Server 2008 R2

Discontinued Database Engine Functionality in SQL Server 2008

Discontinued Database Engine Functionality in SQL Server 2005

Deprecated Commands in SQL Server 2005