In SQL Server, you can use the FILE_IDEX()
function to return the ID of a given database file. You can also use the FILE_ID()
function to do the same thing. Both functions serve pretty much the same purpose, so why does T-SQL have both functions?
It appears that FILE_IDEX()
is a replacement for FILE_ID()
, and it supports a larger range of file IDs. Microsoft now recommends against using FILE_ID()
, as it’s in maintenance mode and may be removed in a future version of SQL Server.
So if you’re looking for a quick answer for which function to use, use FILE_IDEX()
.
But if you’re interested in the difference between these two functions, read on.
Continue reading →