FILE_ID (Transact-SQL)

FILE_ID (Transact-SQL)

 

THIS TOPIC APPLIES TO:yesSQL Server (starting with 2008)noAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

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

System_CAPS_ICON_important.jpg Important


This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use FILE_IDEX instead.

Topic link icon Transact-SQL Syntax Conventions

  
FILE_ID ( file_name )  

file_name
Is an expression of type sysname that represents the name of the file for which to return the file ID.

smallint

file_name corresponds to the logical file name displayed in the name column in the sys.master_files or sys.database_files catalog views.

In SQL Server, the file identification number assigned to full-text catalogs is greater than 32767. Because the return type of the FILE_ID function is smallint, this function cannot be used for full-text files. Use FILE_IDEX instead.

The following example returns the file ID for the AdventureWorks_Data file.

USE AdventureWorks2012;  
GO  
SELECT FILE_ID('AdventureWorks2012_Data')AS 'File ID';  
GO  

Here is 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)

Community Additions

ADD
Show:
© 2016 Microsoft