Search

Monday, October 28, 2013

SQL performance slowing down

I was working on a database since last couple of month. Suddenly it was slowing down day by day. I had not changes anything in the database. 

Then I checked the database properties and found that recovery model was set to Full. 
Full recovery model was not needed as I do not use incremental backup. 
So I set recovery model to Simple and my problem is solved.

Monday, October 21, 2013

Change Database compatibility level

You can change the database compatibility level through Management Studio. (Go to Database Properties - Option).

Here is the script to change the database compatibility level through SQL:

ALTER DATABASE <DB_Name> SET SINGLE_USER 
GO 
EXEC sp_dbcmptlevel <DB_Name>, 100; 
GO 
ALTER DATABASE <DB_Name> SET MULTI_USER 
GO

In above script change <DB_Name> with Database Name (you want to change the compatibility level).

Compatibility Level :

SQL Server 2008 : 100
SQL Server 2005 : 90
SQL Server 2000 : 80
SQL Server 7.0 : 70

Monday, October 7, 2013

ACID rule of thumb for transactions

A transaction must be:
  1. Atomic - It is one unit of work and does not dependent on previous and following transactions.
  2. Consistent - Data is either committed or roll back, no ?in-between? case where something has been updated and something hasn't.
  3. Isolated - no transaction sees the intermediate results of the current transaction).
  4. Durable - the values persist if the data had been committed even if the system crashes right after.

Monday, September 30, 2013

Query to get All Databases Size

User below query to find Database Size :

SELECT  d.name AS [Database Name],
        ROUND(SUM(mf.size) * 8 / 1024, 0) [Size (MB)]
FROM    sys.master_files mf
        INNER JOIN sys.databases d ON d.database_id = mf.database_id
WHERE   d.database_id > 4 
GROUP BY d.name 
ORDER BY d.name

Monday, September 23, 2013

Database Engine Tuning Adviser not found

Today, I want to optimize some some queries. I searched the net and found that we can use Database Engine Tuning Adviser for this. But I could not found that in SSMS. 

Again I searched the net and found that it is not available with SQL server express edition.

So I uninstalled the SQL Server Express Edition and  installed SQL Server Developer Edition. 

Now I got the Database Engine Tuning Adviser