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

This is a discussion on Determining which tables are in which file group via T-SQL within the sqlserver-tools forums in Microsoft SQL Server category; 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....

Go Back   Database Forum > Microsoft SQL Server > sqlserver-tools

Database Forums

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-15-2008, 01:35 PM
Default Determining which tables are in which file group via T-SQL

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.

Reply With Quote
  #2  
Old 08-27-2008, 11:39 AM
Default RE: Determining which tables are in which file group via T-SQL


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/200...mong-file.html
Reply With Quote
Reply


Thread Tools
Display Modes



All times are GMT -4. The time now is 08:02 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Integrated by bbpixel2008 :: jvbPlugin R1013.368.1

Search Engine Friendly URLs by vBSEO 3.1.0
vB Ad Management by =RedTyger=
In an effort to better serve ads to our visitors, cookies are used on Mydatabasesupport.com. For more information, check out our Privacy Policy.