Thanks for the script to check the filegroup on partition. But what I wanted to know is can we just defrag all tables which are only on filegroup XXX_2012.
Yes, we can do the defrag manually using
DBCC Indexdefrag (Database,"tablename", index) but I want a script which runs defrag on XXX_2012 filegroup only for all indexes.