Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 SQL Server uptime

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-04-26 : 11:02:23
Brad writes "I am looking for a T-SQL script that will tell me how long an sql server has been operating.

thanks"

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2002-04-26 : 11:51:00
This works for me:

select crdate from master..sysdatabases
where name = 'tempdb'


Edited by - YellowBug on 04/26/2002 11:54:38
Go to Top of Page

VyasKN
SQL Server MVP & SQLTeam MVY

313 Posts

Posted - 2002-04-26 : 11:54:49
Please read this FAQ entry at my site:
http://vyaskn.tripod.com/programming_faq.htm#q3

--
HTH,
Vyas
Check out my SQL Server site @
http://vyaskn.tripod.com
Go to Top of Page

SQLServerDBA_Dan
Aged Yak Warrior

752 Posts

Posted - 2002-04-26 : 12:06:21
Other than those you could:

If you use SQL Agent and it starts when SQL starts and you dont need a "to the exact second time" you could use this:

select datediff(n, login_time, getdate()) as [minutes of uptime]
from master..sysprocesses
where program_name = 'SQLAgent - Generic Refresher'

But you'd have to remember not to restart the agent.

But I really think the best way is probably to read the error log like VyasKN suggested...

Daniel
SQL Server DBA
Go to Top of Page

VyasKN
SQL Server MVP & SQLTeam MVY

313 Posts

Posted - 2002-04-26 : 12:08:37
Reading the error log will work, if you are not cycling the error log.

--
HTH,
Vyas
Check out my SQL Server site @
http://vyaskn.tripod.com
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-04-27 : 00:40:16
Here is a script to do it

http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=14003

Hope that helps

Damian

Stay on this SQL Server site
Go to Top of Page

VyasKN
SQL Server MVP & SQLTeam MVY

313 Posts

Posted - 2002-04-27 : 08:07:34
quote:

Here is a script to do it

http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=14003

Hope that helps

Damian

Stay on this SQL Server site


This again has the same disadvantage...isn't it? It will not work if the error log is cycled using sp_cycle_errorlog. Especially, in my case, I cycle the log every night, so the error logs remains small and manageable.

--
HTH,
Vyas
Check out my SQL Server site @
http://vyaskn.tripod.com
Go to Top of Page
   

- Advertisement -