How to find unique SQL queries out of SQL server trace log queries

758 Views Asked by At

I would like to process massive amount of SQL queries and only keep unique ones. I mean same queries with different parameters will be removed and only 1 signature query will be left for each unique query.

Now what i am asking in this question is the programming logic. Pseudo code perhaps or real .net code. Or any third party plugin/software/framework which is free.

Here example case:

    select PathSquares from tblPathFinding where RouteId=470 
and StartingSquareId=267 and ExitSquareId=13;

    select PathSquares from tblPathFinding where RouteId=470 
and StartingSquareId=267 and ExitSquareId=1472;

As you can see above queries, they are actually same query with different parameter. So with a logic, i need to eliminate such duplicate queries and keep only 1 which would be enough for Database Engine Tuning Advisor.

What kind of logic and approach should i follow to detect duplicate queries ?

Waiting your suggestions ty

I will use .net 4.5 C# WPF application to solve this problem

1

There are 1 best solutions below

2
On

I don't know the programming logic but I can point you to an application I've used that does this. The ClearTrace application takes a SQL Server trace and "normalizes" all the queries within the trace.

They were somehow able to understand what could be replaced as a variable within a query.

enter image description here