FILEPROPERTY (Transact-SQL)

 

THIS TOPIC APPLIES TO:yesSQL Server (starting with 2008)noAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

Returns the specified file name property value when a file name in the current database and a property name are specified. Returns NULL for files that are not in the current database.

Topic link icon Transact-SQL Syntax Conventions

  
FILEPROPERTY ( file_name , property )  

file_name
Is an expression that contains the name of the file associated with the current database for which to return property information. file_name is nchar(128).

property
Is an expression that contains the name of the file property to return. property is varchar(128), and can be one of the following values.

ValueDescriptionValue returned
IsReadOnlyFilegroup is read-only.1 = True

0 = False

NULL = Input is not valid.
IsPrimaryFileFile is the primary file.1 = True

0 = False

NULL = Input is not valid.
IsLogFileFile is a log file.1 = True

0 = False

NULL = Input is not valid.
SpaceUsedAmount of space that is used by the specified file.Number of pages allocated in the file

int

file_name corresponds to the name column in the sys.master_files or sys.database_files catalog view.

The following example returns the setting for the IsPrimaryFile property for the AdventureWorks_Data file name in AdventureWorks2012 the database.

  
SELECT FILEPROPERTY('AdventureWorks2012_Data', 'IsPrimaryFile')AS [Primary File];  
GO  

Here is the result set.

Primary File   
-------------  
1  
(1 row(s) affected)  

FILEGROUPPROPERTY (Transact-SQL)
Metadata Functions (Transact-SQL)
sp_spaceused (Transact-SQL)
sys.database_files (Transact-SQL)
sys.master_files (Transact-SQL)

Community Additions

ADD
Show: