I want some Moore

Blog about stuff and things and stuff. Mostly about SQL server and .Net
posts - 219, comments - 2287, trackbacks - 33

My Links

Advertisement

News

Hi! My name is 
Mladen Prajdić  I'm from Slovenia and I'm currently working as a .Net (C#) and SQL Server developer.

I also speak at local user group meetings and conferences like SQLBits and NT Conference
Welcome to my blog.
SQL Server MVP

My Books

SQL Server MVP Deep Dives 2
The Red Gate Guide to SQL Server Team based Development Free e-book

My Blog Feed via Email
Follow MladenPrajdic on Twitter


Users Online: who's online

Article Categories

Archives

Post Categories

Cool software

Other Blogs

Other stuff

SQL stuff

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 :))

 

kick it on DotNetKicks.com

Print | posted on Thursday, July 16, 2009 6:55 PM | Filed Under [ SQL Server ]

Feedback

Gravatar

# re: How to check when was SQL Server installed with a T-SQL query

Work like a champ! Good work. Thanks

~JL
7/16/2009 7:10 PM | Jeffrey Langdon
Gravatar

# 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
7/17/2009 3:00 PM | Madhivanan
Gravatar

# 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'
7/17/2009 3:02 PM | Mladen
Gravatar

# 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.
7/18/2009 9:16 PM | Nagi
Comments have been closed on this topic.

Powered by:
Powered By Subtext Powered By ASP.NET