Applies to: 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.
Transact-SQL syntax conventions
SyntaxFILEPROPERTY ( 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).
propertyAn 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 returnedIsReadOnly
File is read-only. 1 = True
IsPrimaryFile
File is the primary file. 1 = True
IsLogFile
File is a log file. 1 = True
SpaceUsed
Amount of space that is used by the specified file. Number of pages allocated in the file Return types
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 AdventureWorks2022 the database.
SELECT FILEPROPERTY('AdventureWorks2022_Data', 'IsPrimaryFile') AS [Primary File];
GO
Here's the result set.
Primary File
-------------
1
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4