FILE_IDEX()

This function returns the file identification (ID) number for the specified logical name of a data, log, or full-text file of the current database.

Signature

FILE_IDEX ( file_name )

Parameters

  • file_name — An expression of type sysname that returns the file ID value 'FILE_IDEX' for the name of the file.

Examples

SELECT FILE_IDEX((SELECT name FROM sys.master_files WHERE type = 4))  
AS 'File_ID';
NULL

Run against SQL Server 16.0.4265.3 on 2026-09-13. This is the output we got, not the documentation’s.

Want to run this against your own SQL Server server from an iPhone, iPad or Mac? These are ours — every connection goes straight from the device to your database, with no account and no server of ours in between.

Signature and description adapted from the Microsoft SQL documentation, used under the CC BY 4.0. SQL Server and Azure are trademarks of the Microsoft group of companies. This page is not affiliated with Microsoft.