Home > SQL Server > File_ID, File_IDEX, File_Name and FileProperty functions – SQL Server

File_ID, File_IDEX, File_Name and FileProperty functions – SQL Server


FILE_ID(‘database logical file name’) : This function returns the file identification number for the given database logical name. This function will be removed from the future version of SQL Server. It returns a small integer value as file id.

FILE_IDEX(‘database logical file name’) : This function is same as the File_ID(). But, This is the replacement function for File_ID(). This function returns integer value for file id and null for error in argument.

FILE_NAME(file id) : This function returns the database logical file name for a given file id.

FILEPROPERTY(‘database logical file name’, property) : This function returns the file property value such as IsReadOnly, IsPrimaryFile, IsLogFile and SpaceUsed. It returns an integer value. It gives 1=true, 0=false or NULL = error.

Catalog views

sys.master_files : It contains database file information stored in the master database.

sys.database_files : It contains current database file names.

Implementation

1. Get database file details using sys.master_files

pic12. Get current database file information using sys.database_files

pic23. Get file id and name using file_id() and file_name() functions

pic34. Get file property value using fileproperty()

pic5

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: