sp_helpfile (Transact-SQL)sp_helpfile (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 physical names and attributes of files associated with the current database. 請利用這個預存程序來判斷伺服器所要附加或卸離的檔案名稱。Use this stored procedure to determine the names of files to attach to or detach from the server.

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

語法Syntax

  
sp_helpfile [ [ @filename= ] 'name' ]  

引數Arguments

[ @filename = ] 'name' 這是目前資料庫中的任何檔案邏輯名稱。[ @filename = ] 'name' Is the logical name of any file in the current database. 名稱sysname,預設值是 NULL。name is sysname, with a default of NULL. 如果名稱是未指定,會傳回目前資料庫中的所有檔案的屬性。If name is not specified, the attributes of all files in the current database are returned.

傳回碼值Return Code Values

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

結果集Result Sets

資料行名稱Column name 資料類型Data type 描述Description
namename sysnamesysname 邏輯檔案名稱。Logical file name.
fileidfileid smallintsmallint 檔案的數值識別碼。Numeric identifier of the file. 如果不會傳回名稱指定 Is not returned if name is specified .
filenamefilename nchar(260)nchar(260) 實體檔案名稱。Physical file name.
filegroupfilegroup sysnamesysname 檔案所屬的檔案群組。Filegroup in which the file belongs.

NULL = 檔案是記錄檔。NULL = File is a log file. 它永遠不在檔案群組中。This is never a part of a filegroup.
sizesize nvarchar(15)nvarchar(15) 檔案大小 (以 KB 為單位)。File size in kilobytes.
maxsizemaxsize nvarchar(15)nvarchar(15) 檔案所能成長的大小上限。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 that new space is required.

0 = 檔案是固定大小,不會成長。0 = File is a fixed size and will not grow.
使用方式usage varchar(9)varchar(9) 對於資料檔,這個值是 '僅限資料' 的值是記錄檔僅限記錄'For data file, the value is 'data only' and for the log file the value is 'log only'.

PermissionsPermissions

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

範例Examples

下列範例會傳回 AdventureWorks2012AdventureWorks2012 中之檔案的相關資訊。The following example returns information about the files in AdventureWorks2012AdventureWorks2012.

USE AdventureWorks2012;  
GO  
EXEC sp_helpfile;  
GO  

另請參閱See Also

Database Engine 預存程序(Transact SQL) Database Engine Stored Procedures (Transact-SQL)
sp_helpfilegroup (Transact-SQL) sp_helpfilegroup (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