Wednesday, March 7, 2012

how to know which filegroup a table is using with a SQL query

there are several filegroups
I want to know which filegroup a table is using with a SQL query
(i think there may be a SYSTEM TABLE I can query to know it)Benny
select
object_name(i.id) as table_name,
groupname as [filegroup]
from sysfilegroups s, sysindexes i
where i.id in (object_id('tablename'))
and i.indid < 2
and i.groupid = s.groupid
"Benny" <wuyuebing@.gmail.com> wrote in message
news:1178688427.945823.281780@.e65g2000hsc.googlegroups.com...
> there are several filegroups
> I want to know which filegroup a table is using with a SQL query
> (i think there may be a SYSTEM TABLE I can query to know it)
>|||On May 9, 1:54 pm, "Uri Dimant" <u...@.iscar.co.il> wrote:[vbcol=seagreen]
> Benny
> select
> object_name(i.id) as table_name,
> groupname as [filegroup]
> from sysfilegroups s, sysindexes i
> where i.id in (object_id('tablename'))
> and i.indid < 2
> and i.groupid = s.groupid
> "Benny" <wuyueb...@.gmail.com> wrote in message
> news:1178688427.945823.281780@.e65g2000hsc.googlegroups.com...
>
>
from your query, I found it is based on index's filegroup,
so how about if some table do not have index?
and how about .indid >= 2 ?

No comments:

Post a Comment