欢迎来到福编程网,本站提供各种互联网专业知识!
您的位置:网站首页 > 数据库 > MsSql

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

发布时间:2015-07-08 作者:投稿junjie 来源:转载
这篇文章主要介绍了SQLServer根据分区表名查找所在的文件及文件组实现脚本,本文直接给出实现代码,需要的朋友可以参考下
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'

相关推荐