Monday, November 13, 2006

Finding your group(file)

Managing tables into filegroups can be a very daunting task when you start to look at huge database systems. The following script always helps me to locate what table is in which filegroup.

It helps to keep things neat and tidy.

SELECT o.name, s.groupname, f.name
FROM dbo.sysfilegroups s
INNER JOIN dbo.sysindexes i
ON i.groupid = s.groupid
INNER JOIN dbo.sysfiles f
ON f.groupid = s.groupid
INNER JOIN dbo.sysobjects o
ON i.id = object_id(o.name)
AND i.indid in (0, 1)

No comments:

Post a Comment