DECLARE @SQLServiceRestartDateTime AS VARCHAR(50), @ServerRestartDateTime AS VARCHAR(50) SELECT @SQLServiceRestartDateTime = create_date FROM sys.databases WHERE database_id=2 SELECT @ServerRestartDateTime = CAST(DATEADD(SECOND, (ms_ticks/1000) * -1, GETDATE()) AS datetime) FROM sys.dm_os_sys_info SELECT @SQLServiceRestartDateTime AS [SQL Service Start DateTime], @ServerRestartDateTime AS [Server Start DateTime]
Wednesday, May 25, 2022
T-SQL to find Server and SQL restart date time
This script comes handy when you would like to find out the Server and SQL services restart times.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment