FILE_NAME (Transact-SQL)


THIS TOPIC APPLIES TO:yesSQL Server (starting with 2008)noAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

Returns the logical file name for the given file identification (ID) number.

Topic link icon Transact-SQL Syntax Conventions

FILE_NAME ( file_id )   

Is the file identification number for which to return the file name. file_id is int.


file_ID corresponds to the file_id column in the sys.master_files or sys.database_files catalog views.

The following example returns the file names for file_ID 1 and file_ID in the AdventureWorks2012 database.

SELECT FILE_NAME(1) AS 'File Name 1', FILE_NAME(2) AS 'File Name 2';  

Here is the result set.

File Name 1 File Name 2

---------------- ------------------------

AdventureWorks2012_Data AdventureWorks2012_Log

(1 row(s) affected)

FILE_IDEX (Transact-SQL)
Metadata Functions (Transact-SQL)
sys.database_files (Transact-SQL)
sys.master_files (Transact-SQL)

Community Additions