SQL code to identify the queries and procedures consuming most I/O and with bad performance
Category: Stored Procedures
What are SQL Query Hints?
SQL server usually selects the best query plan required to execute a T-SQL query. However, there might be cases where … More
Advantages and differences between CHAR and VARCHAR datatypes in SQL Server
Everyone reading this must have come across these datatypes, but have you ever thought what are the differences and advantages … More
The string function SOUNDEX() and its purpose in SQL.
The Soundex code was developed to help negate the effects of all the spelling variations that can occur for similar … More
what does NULLIF() do ? how is it different from ISNULL()?
NULLIF( ) : Returns a null value if the two expressions specified in the function are equal. The syntax used … More
Set Nocount On – Hide the number of records affected by a query
Often it might be necessary to hide the number of records affected by a query. It can be a simple … More
GUID (Globally Unique Identifier) in SQL Server
The GUID (uniqueidentifier) data type is one of the most interesting data types available. uniqueidentifier column holds a GUI, a … More
Functions to get the current system datetime in SQL Server
There are different ways of fetching the current time from the sql server. Sql server 2005 provides 3 different functions … More
What is @@IDENTITY ?
Very often, it is important to check the last identity value inserted into a table. This can be easily done … More
Get the consolidated size of all tables in a database.
The first thing that goes through your mind might be ” why cant we SP_SPACEUSED instead ? “. You are … More
Check for the existence of a string in all procs and functions within a database.
Many developers have asked me, if there is any way to check the existence of a string or text with … More
Some SQL best practices
I had been seeing lot of SQL best practices posts on the web. I found some points missing in many of these … More
Insert values into IDENTITY column of SQL server table / Disable IDENTITY Column in SQL server 2005
Identity columns automatically inserts value for each record inserted into the table . These columns are commonly used as primary … More
Get the owner of the database in SQL server
Sometimes it is important to get the owner of each database in a server. You can do this by checking … More
Executing dynamic queries with more than 4000 characters using variables
Usually problem occurs when we are trying to build a query dynamically and if the length exceeds 4000 characters ( … More
Perform an action on all tables in a database using ‘sp_msforeachtable’
You might have faced a challenge to perform some operation on all the tables in a database. For example truncate … More
Resolving Datetime datatype Issues during insert/select
The developers who work on sql servers, located across the globe, face various issues related to datetime formats used. Some … More