Madhivanan's TSQL Blog

Consider the following CREATE TABLE statementsCREATE TABLE emp1(emp_id int,)
GO
CREATE TABLE emp2(emp_id int,first_name varchar(50),)
GONote that there is extra comma after the datatype of last column. But SQL Server ignores it and execute them without ...

SQL Server Integration Services (SSIS) is one of the tools that can be effectively used to transfer data to various destinations. In versions prior to 2005, we had Import/Export wizard which was part of Database Engine and a package would be created bas...

I have posted a blog post about Different ways to find DISTINCT values where I have shown six different ways to find DISTINCT values. Here is the analysis of how long each method takes.
Create a temporary table named #sales_detailscreate table #sales_de...

There was a question in the SQL forums that the user wanted to remove leading zeroes in the numbers from a varchar column. The column will have numbers, alphabets or alpha-numeric strings. Only numbers should be considered for removing the leading zeroe...

Finding distinct values is often needed in such cases like finding distinct items that were sold last month, etc. You can very well use DISTINCT keyword to do this. However there are some other ways too to find distinct values
Consider the following set...

There was a question in the forums where a user asked for a solution to find out the number which is succeeded by the last 0 in that number
For example, in numbers like 10807023 and 1000508, 23 and 8 are the numbers which are succeeded by the last 0 of...

I see developers often confused on how they get the list of objects by IntelliSense when writing the code. Here are some points on how you can intelligently make use of IntelliSense.
When IntelliSense is enabled, in the query window, type SELECT and a s...

Arithmetic operators are used to perform arithmetic operations like addition, subtraction, multiplication and division. However the operators + ,- and ~ can also be used as unary operators to decide if a number is positive or negative. But we can have f...