sp_helpfilegroup (Transact-SQL)sp_helpfilegroup (Transact-SQL)

適用於: 是SQL Server 否Azure SQL Database 否Azure Synapse Analytics (SQL DW) 否平行處理資料倉儲 APPLIES TO: yesSQL Server noAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

傳回目前資料庫之相關檔案群組的名稱和屬性。Returns the names and attributes of filegroups associated with the current database.

主題連結圖示 Transact-SQL 語法慣例Topic link icon Transact-SQL Syntax Conventions


sp_helpfilegroup [ [ @filegroupname = ] 'name' ]  


[ @filegroupname = ] 'name' 這是目前資料庫中的任何檔案群組邏輯名稱。[ @filegroupname = ] 'name' Is the logical name of any filegroup in the current database. 名稱sysname,預設值是 NULL。name is sysname, with a default of NULL. 如果名稱未指定,則列出目前資料庫中的所有檔案群組,並顯示只有第一個結果集的結果集一節所示。If name is not specified, all filegroups in the current database are listed and only the first result set shown in the Result Sets section is displayed.

傳回碼值Return Code Values

0 (成功) 或 1 (失敗)0 (success) or 1 (failure)

結果集Result Sets

資料行名稱Column name 資料類型Data type 描述Description
groupnamegroupname sysnamesysname 檔案群組的名稱。Name of the filegroup.
groupidgroupid smallintsmallint 數值檔案群組識別碼。Numeric filegroup identifier.
filecountfilecount intint 檔案群組中的檔案數目。Number of files in the filegroup.

如果名稱已指定,會傳回一個資料列群組中的每個檔案。If name is specified, one row for each file in the filegroup is returned.

資料行名稱Column name 資料類型Data type 描述Description
file_in_groupfile_in_group sysnamesysname 檔案群組中該檔案的邏輯名稱。Logical name of the file in the filegroup.
fileidfileid smallintsmallint 數值檔案識別碼。Numeric file identifier.
filenamefilename nchar(260)nchar(260) 檔案的實體名稱 (包含目錄路徑在內)。Physical name of the file including the directory path.
sizesize nvarchar(15)nvarchar(15) 檔案大小 (以 KB 為單位)。File size in kilobytes.
maxsizemaxsize nvarchar(15)nvarchar(15) 檔案的大小上限。Maximum size of the file.

這是檔案所能成長的大小上限。This is the maximum size to which the file can grow. 這個欄位中的 UNLIMITED 值指出,檔案將成長到磁碟已滿。A value of UNLIMITED in this field indicates that the file grows until the disk is full.
成長growth nvarchar(15)nvarchar(15) 檔案的成長遞增。Growth increment of the file. 這表示每次需要新空間時,檔案所增加的空間量。This indicates the amount of space added to the file every time new space is required.

0 = 檔案是固定大小,不會成長。0 = File is a fixed size and will not grow.


需要 public 角色的成員資格。Requires membership in the public role.


A.A. 傳回資料庫中所有的檔案群組Returning all filegroups in a database

下列範例會傳回 AdventureWorks2012AdventureWorks2012 範例資料庫中檔案群組的相關資訊。The following example returns information about the filegroups in the AdventureWorks2012AdventureWorks2012 sample database.

USE AdventureWorks2012;  
EXEC sp_helpfilegroup;  

B.B. 傳回檔案群組中所有的檔案Returning all files in a filegroup

下列範例會傳回 AdventureWorks2012AdventureWorks2012 範例資料庫的 PRIMARY 檔案群組中之所有檔案的相關資訊。The following example returns information for all files in the PRIMARY filegroup in the AdventureWorks2012AdventureWorks2012 sample database.

USE AdventureWorks2012;  
EXEC sp_helpfilegroup 'PRIMARY';  

另請參閱See Also

Database Engine 預存程序(Transact SQL) Database Engine Stored Procedures (Transact-SQL)
sp_helpfile (Transact-SQL) sp_helpfile (Transact-SQL)
sys.database_files (Transact-SQL) sys.database_files (Transact-SQL)
sys.master_files (Transact-SQL) sys.master_files (Transact-SQL)
sys.filegroups (Transact-SQL) sys.filegroups (Transact-SQL)
系統預存程序 (Transact-SQL) System Stored Procedures (Transact-SQL)
資料庫檔案與檔案群組Database Files and Filegroups