![]() |
|
|
By: Tim Ford | Read Comments (2) | Print Tim is a Senior Database Administrator and SQL Server MVP. He has been working with SQL Server since 1999. Related Tips: More |
|
Problem
I am frequently asked to translate the databases that reside on a physical server / SQL instance into their corresponding application names. Typically this need arises when preparing planned downtime notifications for servers, but it also is valuable when communicating to other IT Managers or non-technical staff in my organization. Unless you are the Database Administrator or the Application Analyst for a particular database you are usually oblivious to the naming conventions of the databases that support the applications you rely upon daily. This is why it is important to have the metadata repository in place to provide that translation when the need arises.
Solution
Most DBAs have some form of database metadata repository they rely upon to keep track of their sprawling Microsoft SQL Server environment. I built the one I used in my environment over seven years ago using linked servers and distributed database calls. It was not pretty, but it was functional. Like many IT Developers and DBAs I was proud of my creation, even with its flaws. It was slow, not as streamlined as it could be, and not as secure as it should be.
Upon reading the May and June 2007 SQL Server Magazine articles on SQL Server Integration Services (SSIS) and DBA Repositories by Rodney Landrum I knew it was time to adopt someone else's solution. It was perfect for my environment and with a few modifications was easily-adoptable. In February 2008, a follow-up article was published in SQL Server Magazine in which Rodney updated his solution. I downloaded the code, vetted it in my test environment, and quickly incorporated it into production. While generally pleased with what this solution offered, one of the aspects missing from his package was the ability to correlate databases to applications. By adding two additional tables to his solution I was able to add application metadata that existed in my "home-grown" metadata repository into the one I was now using courtesy of SQL Server Magazine.
Adding application metadata to my repository consisted of creating two tables: dbo.Applications, specifically for storing the application names for all programs relying upon SQL Server databases in my environment, and dbo.Database_Applications which holds the relationship between SQL instance, database, and application.
|
|
You may notice that I did not normalize the dbo.Database_Applications table. If I had, I would only be storing two fields: a foreign key relating back to the table storing my application metadata, and a foreign key corresponding to my database metadata. I have my reasons:
After the daily load of data from my environment I am able to get a good representation of any new databases created in my environment by utilizing the following script:
|
|
The results for this query provide a list of any databases created since the last time I updated my application metadata and serves not only as a notice of database creation activity across the domain, but also as a list to work from for updating the two tables in that correspond to application information. This query also serves as the dataset for a SQL Server Reporting Services report that provides me with a daily notification of new databases to my Blackberry while not in the office.
Finally, I've created the following stored procedure for populating the dbo.Applications and dbo.Database_Applications tables with any new database information. It accepts three parameters: Server, Database, and Application. If the application does not already exist in the dbo.Applications table it is added. Then a record is inserted into the dbo.Database_Applications table for the Server/Database/Application relationship.
|
|
While I could easily incorporate the execution of this stored procedure as the final step in the SQL Server Integration Services package that populates my repository database I choose to not do so in order to keep a closer eye on the activity surrounding new database creation in my environment.
Next Steps
| Share: | Share | Tweet |
|
![]() |
![]() |
Free SQL Server Learning |
| Wednesday, August 20, 2008 - 12:19:47 AM - ALZDBA | Read The Tip |
|
Are you also challenging your metadata to the actual usage ? (by sampling sysprocesses (sql2000) or using a login trigger on sql2005/2008) I'm using this proc on sql2000 for license checking and connection tracking: /* ALZDBA dd 20080715 if object_id('dbo.T_DBA_ConnectionTracker') is null /* Update registered connections */ /* Select * */
/* Install corresponding job */ -- Add the job -- Add the job steps IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback -- Add the job schedules -- Add the Target Servers END |
|
| Wednesday, August 27, 2008 - 8:18:24 AM - jubdavis | Read The Tip |
|
What parameters are needed to execute the pAddApplication proc?
It's looking for ServerName, DatabaseName and ApplicationName. |
|
|
privacy | disclaimer | copyright | advertise | about authors | contribute | feedback | giveaways | user groups Some names and products listed are the registered trademarks of their respective owners. Edgewood Solutions LLC | MSSharePointTips.com | MSSQLTips.com |