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.
| 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..sysdatabaseswhere name = 'tempdb'Edited by - YellowBug on 04/26/2002 11:54:38 |
 |
|
|
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,VyasCheck out my SQL Server site @http://vyaskn.tripod.com |
 |
|
|
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..sysprocesseswhere 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...DanielSQL Server DBA |
 |
|
|
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,VyasCheck out my SQL Server site @http://vyaskn.tripod.com |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
|
|
VyasKN
SQL Server MVP & SQLTeam MVY
313 Posts |
Posted - 2002-04-27 : 08:07:34
|
quote: Here is a script to do ithttp://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=14003Hope that helpsDamianStay 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,VyasCheck out my SQL Server site @http://vyaskn.tripod.com |
 |
|
|
|
|
|