About Me

Followers

My Visual Studio Achievements

Twitter

Thursday, July 28, 2011

This is just a sql puzzle which raised during a long wait for the QA results on a build day.The puzzle seems simple.

Need to insert the records with out duplicates.

The query should consider all the fields.

The query should be single line.ie single statement of query execution.

At first it feels simple as a simple where query. But when we start writing we realize that can we write a where clause in a insert query? Simply speaking how can we write a conditional insert query in sql.After we play with the sql server and queries we automatically come to the below query.