sp_helpfile (Transact-SQL)


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.

Applies to: SQL Server (SQL Server 2008 through current version).

Topic link icon Transact-SQL Syntax Conventions

sp_helpfile [ [ @filename= ] 'name' ]  

[ @filename = ] 'name'
Is the logical name of any file in the current database. name is sysname, with a default of NULL. If name is not specified, the attributes of all files in the current database are returned.

0 (success) or 1 (failure)

Column nameData typeDescription
namesysnameLogical file name.
fileidsmallintNumeric identifier of the file. Is not returned if name is specified.
filenamenchar(260)Physical file name.
filegroupsysnameFilegroup in which the file belongs.

NULL = File is a log file. This is never a part of a filegroup.
sizenvarchar(15)File size in kilobytes.
maxsizenvarchar(15)Maximum size to which the file can grow. A value of UNLIMITED in this field indicates that the file grows until the disk is full.
growthnvarchar(15)Growth increment of the file. This indicates the amount of space added to the file every time that new space is required.

0 = File is a fixed size and will not grow.
usagevarchar(9)For data file, the value is 'data only' and for the log file the value is 'log only'.

Requires membership in the public role.

The following example returns information about the files in AdventureWorks2012.

USE AdventureWorks2012;  
EXEC sp_helpfile;  

Database Engine Stored Procedures (Transact-SQL)
sp_helpfilegroup (Transact-SQL)
sys.database_files (Transact-SQL)
sys.master_files (Transact-SQL)
sys.filegroups (Transact-SQL)
System Stored Procedures (Transact-SQL)
Database Files and Filegroups

Community Additions