Category Archives: Database

Query to Check the SQL Server Restart time

You can simply run one of the below query to check the SQL Server last restart time.


SELECT Dateadd(s, ( ( -1 ) * ( osd.[ms_ticks] / 1000 ) ), Getdate()) AS serverrestartdatetime,
       osd.sqlserver_start_time
FROM   sys.[dm_os_sys_info] osd;  

OR

SELECT name,
       crdate
FROM   sys.sysdatabases
WHERE  name = 'tempdb'

Useful Links for Microsoft SQL Server Certification

http://www.microsoft.com/learning/en/us/certification/cert-sql-server.aspx

http://www.microsoft.com/learning/en/us/exam.aspx?ID=70-432

http://www.measureup.com/70-432-TS-Microsoft-SQL-Server-2008-Implementation-and-Maintenance–P586.aspx

https://mcp.microsoft.com/mcp

Clear/Remove SQL Server Services from Services.msc

Problem:- 
One of my friend was installing cluster SQL Server, installation was stopped in the middle of something and he was not able to remove the SQL Server from add/remove programs or SQL Server setup. He has deleted the registry, folder manually but still he can see the SQL Server Services in Services.msc. He called me for the issue, I have provided him the below solution and it will work.

Solution:
1) Go to command prompt and use SC command to delete service

sc delete sqlserveragent
sc delete mssqlserver

2) You have to also delete the services registry entry using regedit
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services

How to take database out of emergency mode?

In SQL Server 2000

sp_configure ‘allow’ ,1
GO
Reconfigure with override
GO
Update sysdatabases set status = status&(~32768) where name = ‘SQLDBPool’
GO
sp_configure ‘allow’, 0
GO
Reconfigure with override
go

IN SQL Server 2005/2008

ALTER DATABASE sqldbpool
SET online