Skip to content

Latest commit

 

History

History
89 lines (72 loc) · 3.09 KB

File metadata and controls

89 lines (72 loc) · 3.09 KB
title FILE_ID (Transact-SQL) | Microsoft Docs
ms.custom
ms.date 03/14/2017
ms.prod sql
ms.prod_service sql-database
ms.service
ms.component t-sql|functions
ms.reviewer
ms.suite sql
ms.technology
database-engine
ms.tgt_pltfrm
ms.topic language-reference
f1_keywords
FILE_ID
FILE_ID_TSQL
dev_langs
TSQL
helpviewer_keywords
IDs [SQL Server], files
file IDs [SQL Server]
FILE_ID function
names [SQL Server], files
identification numbers [SQL Server], files
file names [SQL Server], FILE_ID
ms.assetid 6a7382cf-a360-4d62-b9d2-5d747f56f076
caps.latest.revision 34
author edmacauley
ms.author edmaca
manager craigg
ms.workload Inactive

FILE_ID (Transact-SQL)

[!INCLUDEtsql-appliesto-ss2008-xxxx-xxxx-xxx-md]

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

Important

[!INCLUDEssNoteDepFutureAvoid] Use FILE_IDEX instead.

Topic link icon Transact-SQL Syntax Conventions

Syntax

  
FILE_ID ( file_name )  

Arguments

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

Return Types

smallint

Remarks

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 [!INCLUDEssNoVersion], 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.

Examples

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

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

[!INCLUDEssResult]

File ID   
-------   
1  
(1 row(s) affected)  

See Also

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)