Merging Duplicated data in Tables

//Below code is to merge the duplicated data by Summing the 
//Qty of the duplicated items.
static void MergeData() 
{
//Creating Bufferes tables.
MergingTable temp,temp1;

;
temp.setTmp();

ttsBegin;

//Inserting data into temp buffer table
insert_recordset temp (ItemId,Qty)
select ItemId,Qty from temp1;

//Deleting data from table
delete_from temp1;

//Inserting Data in to table with SUM of Qty
insert_recordset temp1 (ItemId,Qty)
select ItemId,sum(Qty) from temp group by ItemId;

ttsCommit;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s