May 27, 2010 at 3:12 am
How can i tell which FILE my indexes/tables are stored in?
Before everyone shouts, there are plenty of scripts that explore PARTITIONS and FILEGROUPS usage.
If i have multiple FILES assigned to a FILEGROUP, how can i determine the allocation of objects within a FILE?
thanks for your time sql people!
r
May 27, 2010 at 4:06 am
r5d4 (5/27/2010)
If i have multiple FILES assigned to a FILEGROUP, how can i determine the allocation of objects within a FILE?
Objects are stored in individual filegroups. If there are multiple files in a filegroup, the table will likely be striped across all the files. So it's not in one or the other, it's likely in all of them
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 2, 2010 at 9:04 am
Thank you very much for that Gail.
I've managed to add a second file to my PRIMARY file group.
Not very smart, I know.
How Can I remove this file? (Management Studio reports it as being in use).
The following query (from these forums) shows I have nothing in my primary filegroup (I've moved everything to 2 other filegroups 'CoreData' and 'NCIndexes' respectively?
SELECT OBJECT_NAME( i."id" ) AS TableName ,
i."Name" AS IndexName ,
FILEGROUP_NAME( i.groupid ) AS FileGroupName
FROM sysindexes AS i
WHERE ( i.indid IN ( 0 , 1 ) Or i.indid < 255 ) And -- Tables & indexes only
OBJECTPROPERTY( i."id" , 'IsUserTable' ) = 1 And -- User tables only
OBJECTPROPERTY( i."id" , 'IsMSShipped' ) = 0 And -- No system tables
COALESCE( INDEXPROPERTY( i."id" , i."Name" , 'IsStatistics' ) , 0 ) = 0 And -- No Statistics / Auto-Create stats
COALESCE( INDEXPROPERTY( i."id" , i."Name" , 'IsHypothetical' ) , 0 ) = 0 -- No Hypothetical statistics
ORDER BY FileGroupName , TableName , IndexName
thank you
r
June 2, 2010 at 11:46 am
System tables are stored in the primary filegroup and cannot be moved.
You should be able to remove the second file if you first do a shrinkFile with the EmptyFile option
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 3, 2010 at 8:24 am
Worked perfectly, a big thank you 🙂
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply