Hello Geeks, Hope you are all doing good.

First of all, Let me introduce myself to you.My name is Latheesh NK. About me, I am a very passionate SQL Server Developer, who loves scripting and performance tuning activities.

I would like to take this opportunity to thank Amit Bansal to provide me a great platform to share my experiences with SQL Server with you all.I hope, you all will be enjoying and sharing your thoughts as well here.

Recently, I had a request from one of my colleague who was looking for some option to generate a sequential number using MERGE and ROW_NUMBER.

Ok, let me explain the details on the subject. He is having a table with primary key which is an identity Key. He usually load data to this table from other table with a simple MERGE statement as below.

Now, there is a requirement from his client to avoid identity key from the original table(Do not ask me why?,sometimes we dont get the real reason :) ). However, my colleague was looking for MERGE statement to accomodate his needs. Here is one of my try:

Hope, you enjoy the script. I love to hear from you for any other ways, lets have learning and sharing…

Regards, Latheesh NK