views:

36

answers:

2

Hi,

Using Tsql, how can I find out when MS SQL server was installed?

Thanks in advance

+2  A: 

The NT AUTHORITY\SYSTEM login is created when you install SQL Server, so:

SELECT createdate 
    FROM sys.syslogins 
    WHERE name = 'NT AUTHORITY\SYSTEM'

This will return an incorrect result however if you've ever restored the Master database.

Joe Stefanelli
Isn't this only if "local system" is chosen as the service account? The concept is good though: just need to work out the best login to use.
gbn
@gbn: I'm not sure about that. I was under the (perhaps incorrect) impression that this login was always created. I've checked a couple of systems where I'm using a domain account for the service and this query still seems valid on those systems.
Joe Stefanelli
Big thanks.....
Manjot
+1  A: 

It looks like the first 100 principal_id values are reserved in sys.server_principals (SQL Server 2005+). Based on what I see in one of my sys.server_principals (SQL Server 2005, SP3), I'd try this:

SELECT MIN(create_date) FROM sys.server_principals WHERE principal_id > 100
gbn
Great! Thanks you very much
Manjot