Sta*_*ser 5 sql-server-2008 sql-server filegroups datafile files
我在 SQL Server 2008 R2 上有一个包含 5 个 .ndf(辅助)数据文件的数据库。(这些数据文件中的每一个都被分配到一个单独的文件组。)我想知道这些文件中有哪些数据。是否可以?我知道这些文件组中有全文索引(并且由于每个文件组只有一个文件,因此创建这么多文件的唯一目的可能是将全文索引放在不同的文件组中,我不知道)。我想确保除了全文索引之外没有其他数据。
谢谢
以下 SQL 将向您显示您的表和索引位于哪些文件组中,以便您轻松查看任何文件组中是否有不应包含数据的数据。
SELECT f.[name] AS FileGroupName
, o.[name] AS ObjectName
, o.[type] AS [Type]
, i.[name] AS IndexNAme
, i.[index_id] AS IndexId
FROM sys.indexes i
INNER JOIN sys.filegroups f ON i.data_space_id = f.data_space_id
INNER JOIN sys.all_objects o ON i.[object_id] = o.[object_id]
WHERE i.data_space_id = f.data_space_id
AND o.type = 'U' -- User Created Tables
ORDER BY f.[name]
, o.[name]
, o.[type]
, i.[name]
Run Code Online (Sandbox Code Playgroud)
可以在此处查看脚本的完整详细信息