FILEPROPERTY

Transact-SQL Reference

Transact-SQL Reference

FILEPROPERTY

Returns the specified file name property value when given a file name and property name.

Syntax

FILEPROPERTY ( file_name , property )

Arguments

file_name

Is an expression containing 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 containing the name of the file property to return. property is varchar(128), and can be one of these values.

Value Description Value returned
IsReadOnly File is read-only. 1 = True 0 = False
NULL = Invalid input
IsPrimaryFile File is the primary file. 1 = True
0 = False
NULL = Invalid input
IsLogFile File is a log file. 1 = True
0 = False
NULL = Invalid input
SpaceUsed Amount of space used by the specified file. Number of pages allocated in the file

Return Types

int

Examples

This example returns the setting for the IsPrimaryFile property for the master file name in the master database.

USE master
SELECT FILEPROPERTY('master', 'IsPrimaryFile')

See Also

Control-of-Flow Language

DELETE

INSERT

Metadata Functions

SELECT

UPDATE

WHERE