How to check when was SQL Server installed with a T-SQL query
Today on twitter Lori Edwards (@loriedwards) asked how can you check when was SQL Server installed with a T-SQL query. Otherwise this is pretty simple by looking at the creation time of master database (provided you never had to restore it).
But i wanted to find a nice way of doing this without resorting to any xp_ stored procedures. Of course this is possible by looking into the sys.syslogins compatibility view:
SELECT createdate as Sql_Server_Install_Date FROM sys.syslogins where sid = 0x010100000000000512000000 -- language neutral -- loginname = 'NT AUTHORITY\SYSTEM' -- only English language installations
This query actually returns the creation date and time of the NT AUTHORITY\SYSTEM login which gets created when you install SQL Server. This of course won’t work if you had to restore the master database.
Pretty simple if you know where to look :))
Legacy Comments
Jeffrey Langdon
2009-07-16 |
re: How to check when was SQL Server installed with a T-SQL query Work like a champ! Good work. Thanks ~JL |
Madhivanan
2009-07-17 |
re: How to check when was SQL Server installed with a T-SQL query Will this work if the above doesn't return any value? SELECT createdate FROM sys.syslogins where name='NT AUTHORITY\NETWORK SERVICE' http://sqlblogcasts.com/blogs/madhivanan |
Mladen
2009-07-17 |
re: How to check when was SQL Server installed with a T-SQL query yes because you should query for 'NT AUTHORITY\SYSTEM' and not 'NT AUTHORITY\NETWORK SERVICE' |
Nagi
2009-07-18 |
re: How to check when was SQL Server installed with a T-SQL query I have installed SQL on my laptop on 2009-07-12 12:00 but the master db creation date shows as 4/8/2003 9:13:36 AM. Looks like the query gives the correct time but not the master db creation. |