Skip to content

Latest commit

 

History

History
86 lines (64 loc) · 3.01 KB

File metadata and controls

86 lines (64 loc) · 3.01 KB
title FILEPROPERTY (Transact-SQL)
description FILEPROPERTY returns the specified file name property value when a file name in the current database and a property name are specified.
author markingmyname
ms.author maghan
ms.reviewer randolphwest
ms.date 06/05/2025
ms.service sql
ms.subservice t-sql
ms.topic reference
f1_keywords
FILEPROPERTY_TSQL
FILEPROPERTY
helpviewer_keywords
viewing file properties
names [SQL Server], files
displaying file properties
file properties [SQL Server]
FILEPROPERTY function
file names [SQL Server], FILEPROPERTY
dev_langs
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 aren't 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

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

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 File is read-only. 1 = True
0 = False
NULL = Input isn't valid.
IsPrimaryFile File is the primary file. 1 = True
0 = False
NULL = Input isn't valid.
IsLogFile File is a log file. 1 = True
0 = False
NULL = Input isn't 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 [!INCLUDE ssSampleDBnormal] the database.

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

[!INCLUDE ssResult]

Primary File
-------------
1

Related content