FILE_NAME (Transact-SQL)

**APPLIES TO:** ![yes](media/yes.png)SQL Server (starting with 2008) ![no](media/no.png)Azure SQL Database ![no](media/no.png)Azure SQL Data Warehouse ![no](media/no.png)Parallel Data Warehouse

This function returns the logical file name for a given file identification (ID) number.

Topic link icon Transact-SQL Syntax Conventions

Syntax

FILE_NAME ( file_id )   

Arguments

file_id
The file identification number whose file name FILE_NAME will return. file_id has an int data type.

Return Types

nvarchar(128)

Remarks

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

Examples

This 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';  
GO  

Here is the result set.

File Name 1                File Name 2  
-------------------------  ------------------------  
AdventureWorks2012_Data    AdventureWorks2012_Log  

(1 row(s) affected)

See Also

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