Monthly Archives: April 2011

Transfagarashan – a magical road across the mountains

I will start the travelling category with a unique place located here where I live: in Romania. A beautiful and breath taking panorama situated at 2042 m altitude.

In order to reach this place you don’t have to be a trained mountain climber. Pack the bags, with a few friends, find a car and start the adventure. There is an actual road, a paved road that goes across the mountain peak from one… Continue reading

Check Tables & Indexes size for your Database

Before accepting that your database is big because it needs all the data inside it and buy extra storage to overcome the potential space problem, you can find out if the existing space can be reduced by removing unused objects, indexes.

First find out what are the biggest tables:

 

DECLARE @query varchar(100)
DECLARE @schema as sysname
DECLARE @objectname as sysname… Continue reading

Trace DDL & DCL operations in SQL Server Log – fn_trace_gettable

Did you know that starting with SQL 2005 all future versions of SQL allow tracing of all DDL or DCL modifications done on all DB objects?

I was inspired by Jonathan Kehayias blog to dig deeper and check other useful output from the default trace.

Let me remind you what are Data Definition Language (DDL) and Data Control language (DCL) statements:
 
DDL statements: are used to define… Continue reading

How to find out which Queries have non-reusable Query Plans?

Following a post on Stack Exchange asking how to check if a Query Plan of an SQL statement was compiled/re-compiled or cached for the first time, I was driven to write a more detailed explanation on this.

This query will update 1000 rows.
Update t1 set c1 = 10
If I execute it for the first time, SQL needs to create first a Query Plan for it, Compile… Continue reading

Handling SQL Deadlocks – One Resource Conflict

From a DBA point of view, Deadlocks occurred in Production environment are probably the trickiest and time consuming problems to fix. Every time I came across this, it took me a while to understand where it is coming from, why, and how to avoid a particular Deadlock. This blog will go through some types of deadlocks and how to deal with them.

Here I will analyze a Deadlock caused by an After… Continue reading