HiveBrain v1.2.0
Get Started
← Back to all entries
principlesqlMinor

sys.database_files / sys.filegroups VS sys.sysfiles / sys.sysfilegroups

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
database_filessysfilegroupssysfilegroupssysfiles

Problem

These catalog views seem to show the exact same data. What is the point of having multiple system views that seem to show the same thing?

Here is how I proved it is the same data:

select
    fil.name as [FileName],
    fg.name as GroupName
from sys.database_files fil
inner join sys.filegroups fg
on fil.data_space_id = fg.data_space_id

select 
    fil.name as [FileName],
    fg.groupname as GroupName
from sys.sysfiles fil
inner join sys.sysfilegroups fg
on fil.groupid = fg.groupid

Solution

Almost always, backward compatibility. Often for end user compatibility but also for internal purposes.

I'd swear I was reading an article earlier this week that mentioned one of the old views, possibly sysfiles, having been 99% removed during SQL2005 development but the final 1% proved to difficult/risky to eliminate.

As a general rule, target the most recent versions of any system tables/views in your scripts, they're more likely to still be there in subsequent releases.

Context

StackExchange Database Administrators Q#5283, answer score: 3

Revisions (0)

No revisions yet.