Friday, February 24, 2012

Browse mssqlsystemresource.mdf (SQL Server's Resource Database)

Is there a way to have the Resource Database (mssqlsystemresource.mdf) appear
in the list of Databases in SQL Server Management Studio for easy browsing of
it's contents, or is the only browse option to open the MDF file with a text
editor such as notepad?
Thanks.
Chris Jones
Application Development Consultant
Giving credit where credit is due, I found the following info I am about to
post at the following location:
http://www.aspfaq.com/sql2005/show.asp?id=28
Since the engine has hooks that hide the mssqlsystemresource database from
users, you don't have direct access to it through the GUI.
However, there is a way around this:
1.)Determine where the system databse files live, and keep this path handy:
USE master
GO
SELECT REPLACE(filename, 'master.mdf', '')
FROM sys.sysfiles
WHERE fileid = 1
2.)Stop the SQL Server service;
3.)Copy the files mssqlsystemresource.*df -> resource_copy.*df.
NOTE: do *not* rename or remove the mssqlsystemresource files!
4.)Start the SQL Server service;
5.)Run the following code in a new query window:
EXEC sp_attach_db
'Resource_Copy',
'<path from above>resource_copy.mdf',
'<path from above>resource_copy.ldf'
6.)Now, the system will no longer identify this database as a "special"
database
7.)You can easily scan through the names of system objects that might
otherwise be unknown (and browse any code associated with these objects) from
a GUI (like SQL Server Management Studio).
Thanks.
Chris Jones
Application Development Consultant
"Chris" wrote:

> Is there a way to have the Resource Database (mssqlsystemresource.mdf) appear
> in the list of Databases in SQL Server Management Studio for easy browsing of
> it's contents, or is the only browse option to open the MDF file with a text
> editor such as notepad?
> --
> Thanks.
> Chris Jones
> Application Development Consultant
|||Yes, if you start your SQL Server is single user mode.
Why do you need to see the contents? It just contains definitions of stored
procedures and views, and you can get to all those using the
OBJECT_DEFINITION function.
HTH
Kalen Delaney, SQL Server MVP
http://sqlblog.com
"Chris" <Chris@.discussions.microsoft.com> wrote in message
news:83427BEB-8A5E-4A21-B8CC-EF65E1BEF9DD@.microsoft.com...
> Is there a way to have the Resource Database (mssqlsystemresource.mdf)
> appear
> in the list of Databases in SQL Server Management Studio for easy browsing
> of
> it's contents, or is the only browse option to open the MDF file with a
> text
> editor such as notepad?
> --
> Thanks.
> Chris Jones
> Application Development Consultant

No comments:

Post a Comment