| Author |
Topic |
|
Wanderer
Master Smack Fu Yak Hacker
1168 Posts |
Posted - 2002-03-19 : 10:54:05
|
| Hi guys,I'm trying to find a way to get the start time for SQL server on a server, via SQL from a remote machine. That is to say, I would like to try and have machine A find out when SQL started on machine B (and eventually on all specified machines - that list will reside in a table local on machine A).I haven't found a clean way of doing this. so far the best I could come up with is:Select @@servername as Server_Name,login_time from master..sysprocesseswhere spid = 1There got to be a better way, surely ?TIA |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2002-03-19 : 20:01:05
|
I'm so annoyed, I would have thought there was a cool way to do that, and I can not find one The way you are doing it seems to work, the only other thing I can suggest is a proc that runs on startup that logs the server starting in a table somewhere.Damian |
 |
|
|
byrmol
Shed Building SQL Farmer
1591 Posts |
Posted - 2002-03-19 : 20:33:47
|
| I have been playing with @@Idle and @@CPU_Busy...They both return milliseconds since last started...I wold have thought the (@@Idle + @CPU_Busy) would give you the total number of milliseconds since start....Not even close apparently......DavidMTomorrow is the same day as Today was the day before. |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2002-03-19 : 20:40:13
|
| It is in the event log, if you wrote a com object that would read the event log and found the last MSSQLSERVER entry, then called that from a stored proc, that would do it....messy though.Damian |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-03-19 : 20:48:27
|
Or, you could use the xp_readerrorlog stored procedure. It's undocumented, but it's in Ken Henderson'sThe Guru's Guide to Transact-SQLDamian should have something for you in a minute or so that filters out the excess info it reports. |
 |
|
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2002-03-19 : 20:49:03
|
| Isn't there an extended stored proc called xp_readlog that will read the log file? That should have the start time.===============================================Creating tomorrow's legacy systems today.One crisis at a time. |
 |
|
|
byrmol
Shed Building SQL Farmer
1591 Posts |
Posted - 2002-03-19 : 20:51:41
|
| Rob, Graz,Wanderer wants a CLEAN solution..I take that to mean..Documented and (in this case) permissions neutral...DavidMTomorrow is the same day as Today was the day before. |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2002-03-19 : 20:53:03
|
OK, its not ultra clean, but how is this.Create Table #Logs ( Errorlog VarChar(2000), ContinuationRow int)INSERT Into #LogsExec Master..xp_readerrorlogSELECT ERRORLOG, Cast(Substring(ERRORLOG, 1, 22) as DateTime) [Start Date], DateDiff(n, Cast(Substring(ERRORLOG, 1, 22) as DateTime), GetDate()) as [Uptime (Minutes)]FROM #LogsWHERE ERRORLOG Like '%SQL Server is Starting%'DROP Table #Logs Thanks Rob!DamianEdited by - merkin on 03/19/2002 21:00:39 |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-03-19 : 20:55:12
|
quote: Rob, Graz,Wanderer wants a CLEAN solution..I take that to mean..Documented and (in this case) permissions neutral...
We're open to whatever suggestions you have David... |
 |
|
|
Wanderer
Master Smack Fu Yak Hacker
1168 Posts |
Posted - 2002-03-20 : 03:48:46
|
| Alright!!!I knew there was some kind of xp to read logs, but BOL just laughed at me...maybe I should buy The Guru's Guide to Transact-SQL*grin*This definitely is what I was looking for. It is clean enough for me (kinda a muddy guy anyway), and now I can use this to do more than just Start Time!TAG (Thanx Again Guys) |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
|
|
Glockenspiel
Yak Posting Veteran
50 Posts |
|
|
|