Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » Meta Data FunctionsRSS Feeds

FILEPROPERTY Function

Posted By: Sarita Patel     Category: SQL Server     Views: 2239

This article explains about FILEPROPERTY function in sql server with examples.

FILEPROPERTY function is used to get property value for specified file and property name.



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. 
  
Share: 


Didn't find what you were looking for? Find more on FILEPROPERTY Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of FILEPROPERTY Function is from United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!