DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

SQL 2005 TSQL Script To List Tables, Indexes, File Groups Along With File Names

  • submit to reddit
        // description of your code here

select 'table_name'=object_name(  ,i.indid
,'index_name'  ,i.groupid
,'filegroup'  ,'file_name'=d.physical_name
,'dataspace' from sys.sysindexes i
,sys.filegroups f  ,sys.database_files d
,sys.data_spaces s
where objectproperty(,'IsUserTable') = 1
and f.data_space_id = i.groupid
and f.data_space_id = d.data_space_id
and f.data_space_id = s.data_space_id
order by,object_name(,groupid