improvedk / OrcaMDF

A C# parser for MDF files. Allows you to read tables, metadata and indexes from MDF files without it being attached to a running SQL Server instance.
http://improve.dk/archive/2011/05/03/introducing-orcamdf.aspx
GNU General Public License v3.0
181 stars 74 forks source link

You don't seem to expose sys.sysdbreg in OrcaMDF #27

Closed zippy1981 closed 10 years ago

zippy1981 commented 10 years ago

Using the registry and OrcaMDF (and shadow copy), I'd like to be able to inspect all databases on all instances on a server. I can use the registry to get all copies of master.mdf. However, I can't see a list of databases in the masters instance with OrcaMDF. dba.stackexchange.com points me to sys.sysdbreg. I don't see that mentioned anywhere in your code. Can that be exposed by OrcaMDF?

zippy1981 commented 10 years ago

Actually that table is stored in mssqlsystemresource.mdf. However, I don't see it there when I open it in orcamdf.

improvedk commented 10 years ago

This should be doable. Perhaps add it as a base table like all the others, but with a check to see if it actually exists, and if not, make sure the DMVs property value is null. In OMS it should also only be shown if it's actually present on disk.

zippy1981 commented 10 years ago

Are "unknown" base tables something you can scan for and at least get the name of, or arre they things at specific file offsets that you need to look for?

Is it possible to list unknown base tables in OMS?

improvedk commented 10 years ago

All base tables should be inside of sysschobjs. This is currently filtered down to just user tables for the sys.tables DMV. Removing that filter should return base tables as well.

If you look at BaseTableData.cs you'll see that besides a few core tables, all the other base tables are scanned like any other user table:

private IList<sysowner> _sysowners;
internal IList<sysowner> sysowners
{
    get { return _sysowners ?? (_sysowners = scanner.ScanTable<sysowner>("sysowners").ToList()); }
}

So all that needs to be done is to create a table type like sysowner that matches the base table. And preferably you'd perform a lookup in sysschobjs to check whether the table is actually there, and if not, return null. Sysschobjs should be available when you need to access it from a method like the above one.