Select SQL Server database size

Try this one – Query: SELECT database_name = DB_NAME(database_id) , log_size_mb = CAST(SUM(CASE WHEN type_desc=”LOG” THEN size END) * 8. / 1024 AS DECIMAL(8,2)) , row_size_mb = CAST(SUM(CASE WHEN type_desc=”ROWS” THEN size END) * 8. / 1024 AS DECIMAL(8,2)) , total_size_mb = CAST(SUM(size) * 8. / 1024 AS DECIMAL(8,2)) FROM sys.master_files WITH(NOWAIT) WHERE database_id = … Read more

Exit single-user mode

SSMS in general uses several connections to the database behind the scenes. You will need to kill these connections before changing the access mode. First, make sure the object explorer is pointed to a system database like master. Second, execute a sp_who2 and find all the connections to database ‘my_db’. Kill all the connections by … Read more

SQL Server Configuration Manager cannot be found

If you happen to be using Windows 8 and up, here’s how to get to it: The newer Microsoft SQL Server Configuration Manager is a snap-in for the Microsoft Management Console program. It is not a stand-alone program as used in the previous versions of Microsoft Windows operating systems. SQL Server Configuration Manager doesn’t appear … Read more

Script to kill all connections to a database (More than RESTRICTED_USER ROLLBACK)

Updated For MS SQL Server 2012 and above USE [master]; DECLARE @kill varchar(8000) = ”; SELECT @kill = @kill + ‘kill ‘ + CONVERT(varchar(5), session_id) + ‘;’ FROM sys.dm_exec_sessions WHERE database_id = db_id(‘MyDB’) EXEC(@kill); For MS SQL Server 2000, 2005, 2008 USE master; DECLARE @kill varchar(8000); SET @kill=””; SELECT @kill = @kill + ‘kill ‘ … Read more

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated

Looks like you have a query that is taking longer than it should. From your stack trace and your code you should be able to determine exactly what query that is. This type of timeout can have three causes; There’s a deadlock somewhere The database’s statistics and/or query plan cache are incorrect The query is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)