Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Other Technologies / English Query / August 2008

Tip: Looking for answers? Try searching our database.

Determining which tables are in which file group via T-SQL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael B. - 15 Aug 2008 17:35 GMT
I'm trying to figure out how to list what file group every table is in.  I
thought this query was it :

select sys.tables.name,sys.data_spaces.name from sys.tables,sys.data_spaces
where sys.tables.lob_data_space_id = sys.data_spaces.data_space_id order by
sys.tables.name

Until I realised that it only tells me where the LOB objects are.  I've been
beating my head against a wall on this, any guidance?

M.
Tariq - 27 Aug 2008 15:39 GMT
try below query,

SELECT OBJECT_NAME(SI.OBJECT_ID) AS OBJECTNAME
,SI.DATA_SPACE_ID AS FILE_GROUP_ID
,SFG.NAME AS FILE_GROUP_NAME
,SF.NAME AS LOGICAL_FILE_NAME
,SF.FILENAME AS PHYSICAL_FILE_NAME
FROM SYS.INDEXES SI
INNER JOIN SYS.FILEGROUPS SFG ON SFG.DATA_SPACE_ID=SI.DATA_SPACE_ID
INNER JOIN SYS.SYSFILES SF ON SF.GROUPID = SFG.DATA_SPACE_ID
WHERE SI.INDEX_ID IN (0,1)

for further queries about file group,
http://sqlserver4me.blogspot.com/2008/08/how-to-view-association-among-file.html
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.