Finding File-Creation Time

SQL Server doesn't store file-creation times in the system tables. However, if you have a database file's full name you can acquire the file's creation time by using xp_getfiledetails.

Brian Moran

June 21, 2004

1 Min Read
ITPro Today logo in a gray background | ITPro Today

Does SQL Server keep track of when new files and filegroups are added to or removed from a database, maybe in the form of a timestamp in the catalog? If so, how can I access that information?

SQL Server doesn't store file-creation times in the system tables. However, if you have a database file's full name, you can retrieve the file's creation time by using xp_getfiledetails:

EXEC master..xp_getfiledetails 'C:Program FilesMicrosoft SQLServerMSSQL$SQL2000_1datapubs.mdf'

The command's result set will tell you when the file was created, among other things. This technique won't work for retrieving filegroup creation times, however, because filegroups don't have a physical structure at the OS level. I don't know of any way to determine when a filegroup was created or when a particular file was added to a filegroup.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like