FILEPROPERTY (Transact-SQL)
SQL Server 2012
Returns the specified file name property value when a file name in the current database and a property name are specified. Returns NULL for files that are not in the current database.
The following example returns the setting for the IsPrimaryFile property for the AdventureWorks_Data file name in the AdventureWorks database.
USE AdventureWorks2012;
GO
SELECT FILEPROPERTY('AdventureWorks2012_Data', 'IsPrimaryFile')AS [Primary File];
GO
Here is the result set.
Primary File ------------- 1 (1 row(s) affected)