Archive

Archive for the ‘Tips N Tricks’ Category

Monitor T SQL Query performance at millisecond level

September 25th, 2011 7 comments

Many times upon executing any T-SQL queries, we like to know the performance of the query at millisecond level. But SSMS provides us information at second level as below:

SELECT *
FROM   Purchasing.vVendor;

Read more…

Categories: Tips N Tricks

GO ‘N’ Times

September 2nd, 2011 5 comments

One unbelievable tip for the day for T-SQL users.  What a “GO” statement do in T-SQL.

By definition it is a batch separator. It will run a batch and commit it. But along with that it also accepts one parameter which tells the SQL engine basically how many times to do the job.

Read more…

Categories: Tips N Tricks

For each database – sp_MSForEachDB

August 20th, 2010 7 comments

Sp_MSForEachDB is a great procedure coming with MS SQL Server even though it is un-documented. It eases some of the complex operations that we mostly do by using CURSORS.

Read more…

Categories: T - SQL, Tips N Tricks

Top N Random records from each group

October 12th, 2009 5 comments


Problem:

The requirement is to get top 10 employee’s name randomly from each department in a company. Let me elaborate it. Suppose in a company ABC, there are 1500 employees with 5 departments and each department have more than 200 employees. The manager wants to list down at least 10 names of the employees randomly from each department for a survey.

Solution:

Read more…

Categories: Tips N Tricks

Database Summary

October 6th, 2009 No comments
Categories: Tips N Tricks

Total number of days in a month

July 26th, 2009 4 comments


Here are some ways described to find out the total no. of days in a given month.

Read more…

Categories: T - SQL, Tips N Tricks

Last business day of any given month

July 25th, 2009 1 comment
Categories: T - SQL, Tips N Tricks