Merge Join affecting the insert order in table

Posted by Mokkarasu under Sql Server on 2/17/2015 | Points: 10 | Views : 287 | Status : [Member] | Replies : 1
Hi friends,

In my MS SQL procedure am using table type variable as parameter. From front end the data table is created and passed to the stored procedure as parameter.

Grid from UI:

Salary --- MonthOfPayment
600 ------ 3
300 ------ 1
800 ----- 2

I want the data to be inserted in the order in which the user has entered the salary data in the grid. But I noticed while inserting the data 300 always getting inserted first, then 600 and then 800.

In spite of the data table having first row as 600, second row 300 and third row 800 the data keeps inserting in ascending order of salary always.

How to retain the inserting order as passed in the data table.

I have used merge join existing table with the table type paramter. Is it affecting insert order?

Thanks in Advance,
varsha raja


Posted by: Bandi on: 2/17/2015 [Member] [MVP] Platinum | Points: 25

Send the your front-end code how you are calling procedure and the SP ( stored procedure ) logic...

Refer this link

Mark This Response as Answer

Mokkarasu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response