欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

SQL Server根据分区表名查找所在的文件及文件组实现脚本

程序员文章站 2023-01-03 14:49:31
select ps.name as psname, dds.destination_idas partitionnumber, fg.name as...
select ps.name as psname,  
 dds.destination_idas partitionnumber, 
  fg.name as filegroupname,fg.name,
  t.name,
  f.name as filename
  from (((sys.tables as t  
  inner join sys.indexes as i
      on (t.object_id = i.object_id)) 
  inner join sys.partition_schemes as ps 
      on (i.data_space_id = ps.data_space_id)) 
   inner join sys.destination_data_spacesas dds 
      on (ps.data_space_id = dds.partition_scheme_id))
   inner join sys.filegroups as fg  
       ondds.data_space_id =fg.data_space_id
       innerjoin sys.database_files f on f.data_space_id = fg.data_space_id
      where t.name='salesorder'