Can anyone help me to work out below T-SQL code. I am facing issue while adding the second value. The first value gives the state of SQL Service and second value gives the SQL last restart time. I am not a core developer so can anyone help me .
if object_id ('tempdb..#temp1') is not null
drop table tempdb..#temp1
create table #temp1
([Current Service State] nvarchar(200),
[SQL_Server_last_RestartOn]nvarchar(200))
insert into #temp1
EXEC master.sys.xp_servicecontrol N'querystate',N'MSSQLSERVER',
(select min(login_time) from master..sysprocesses) as SQL_Server_last_RestartOn
Best Answer
Give this a try