Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Server Tables + files

Status
Not open for further replies.

sendba

Programmer
Sep 7, 2005
113
US
Hi,

Is there a way to figure out what is being allocated in the data files. for eg I have 10 files on the primary filegroup and wanted to shrink it to 1 in order for me to make different filegroups. The database is huge. Is there any way to determine what is being allocated in a file.

Thanks
Sen
 
This is something I have been after for a while, saw your post and decided to work it out. managed to get there by seeing how SQL managed it, sp_help objectname gave file info which in turn called sp_objectfilegroup which led me to the code I amended below.

Code:
SELECT 
	o.name AS ObjectName,
	s.groupname  AS Data_located_on_filegroup 
FROM 
	sysfilegroups s
JOIN
	sysindexes i  ON i.groupid = s.groupid  
JOIN
	sysobjects o  ON o.id=i.id
WHERE 
	i.indid < 2  AND o.type ='U'
ORDER BY 1 
	Desc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top