title | description | author | ms.author | ms.date | ms.service | ms.subservice | ms.topic | f1_keywords | helpviewer_keywords | dev_langs | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FILE_NAME (Transact-SQL) |
FILE_NAME (Transact-SQL) |
markingmyname |
maghan |
03/03/2017 |
sql |
t-sql |
reference |
|
|
|
[!INCLUDE SQL Server Azure SQL Managed Instance]
This function returns the logical file name for a given file identification (ID) number, in the context of the current database.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
FILE_NAME ( file_id )
file_id
The file identification number whose file name FILE_NAME
will return. file_id has an int data type.
nvarchar(128)
file_ID corresponds to the file_id column in the sys.master_files catalog view or the sys.database_files catalog view.
This example returns the file names for file_ID 1
and file_ID
in the [!INCLUDEssSampleDBnormal] database.
SELECT FILE_NAME(1) AS 'File Name 1', FILE_NAME(2) AS 'File Name 2';
GO
[!INCLUDEssResult]
File Name 1 File Name 2
------------------------- ------------------------
AdventureWorks2022_Data AdventureWorks2022_Log
(1 row(s) affected)
FILE_IDEX (Transact-SQL)
Metadata Functions (Transact-SQL)
sys.database_files (Transact-SQL)
sys.master_files (Transact-SQL)