Skip to content

Latest commit

 

History

History
80 lines (64 loc) · 3.18 KB

fileproperty-transact-sql.md

File metadata and controls

80 lines (64 loc) · 3.18 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
FILEPROPERTY (Transact-SQL)
FILEPROPERTY (Transact-SQL)
markingmyname
maghan
03/03/2017
sql
t-sql
reference
FILEPROPERTY_TSQL
FILEPROPERTY
viewing file properties
names [SQL Server], files
displaying file properties
file properties [SQL Server]
FILEPROPERTY function
file names [SQL Server], FILEPROPERTY
TSQL

FILEPROPERTY (Transact-SQL)

[!INCLUDE SQL Server Azure SQL Managed Instance]

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.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

FILEPROPERTY ( file_name , property )  

Arguments

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.

Value Description Value returned
IsReadOnly Filegroup is read-only. 1 = True

0 = False

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

0 = False

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

0 = False

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

Return Types

int

Remarks

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

Examples

The following example returns the setting for the IsPrimaryFile property for the AdventureWorks_Data file name in [!INCLUDEssSampleDBnormal] the database.

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

[!INCLUDEssResult]

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

See Also

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