Events
Get certified in Microsoft Fabric—for free!
19 Nov, 23 - 10 Dec, 23
For a limited time, the Microsoft Fabric Community team is offering free DP-600 exam vouchers.
Prepare nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to: SQL Server Azure SQL Managed Instance
For the given logical name for a component file of the current database, this function returns the file identification (ID) number.
Important
This feature will be removed in a future version of SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use FILE_IDEX instead.
Transact-SQL syntax conventions
FILE_ID ( file_name )
file_name
An expression of type sysname, representing the logical name of the file whose file ID value FILE_ID
will return.
smallint
file_name corresponds to the logical file name displayed in the name column of the sys.master_files or sys.database_files catalog views.
FILE_ID
returns NULL
if file_name does not correspond to the logical name of a component file of the current database.
In SQL Server, the file identification number assigned to full-text catalogs exceeds 32767. Because the FILE_ID
function has a smallint return type, FILE_ID
will not support full-text files. Use FILE_IDEX instead.
This example returns the file ID value for the AdventureWorks2022_Data
file, a component file of the AdventureWorks2022
database.
USE AdventureWorks2022;
GO
SELECT FILE_ID('AdventureWorks2022_Data')AS 'File ID';
GO
Here's the result set.
File ID
-------
1
(1 row(s) affected)
Deprecated Database Engine Features in SQL Server 2016
FILE_NAME (Transact-SQL)
Metadata Functions (Transact-SQL)
sys.database_files (Transact-SQL)
sys.master_files (Transact-SQL)
Events
Get certified in Microsoft Fabric—for free!
19 Nov, 23 - 10 Dec, 23
For a limited time, the Microsoft Fabric Community team is offering free DP-600 exam vouchers.
Prepare now