Syntax of FILEPROPERTY Function :
FILEPROPERTY ( file_name, property )
file_name is a name of file associated with the current datatbase. It corresponds to the name column in sysfiles. It is of type nchar(128).
property is a name of the file property. It is of type varchar(128) and can be of below values.
Value | Description | Returned Value |
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 type of FILEPROPERTY function is integer.
Examples of FILEPROPERTY Function :
Example 1 : Use of FILEPROPERTY function in select clause
SELECT FILEPROPERTY('Northwind', 'IsPrimaryFile')
Output
1
Above example returns value 1 for property IsPrimaryFile means Northwind file is a default file.