Export (0) Print
Expand All

FILE_NAME (Transact-SQL)

Applies To: SQL Server 2014, SQL Server 2016 Preview

Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).

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

Applies to: SQL Server (SQL Server 2008 through current version).

Topic link icon Transact-SQL Syntax Conventions

FILE_NAME ( file_id ) 

file_id

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

nvarchar(128)

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

Here is the result set.

File Name 1 File Name 2

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

AdventureWorks2012_Data AdventureWorks2012_Log

(1 row(s) affected)

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2015 Microsoft