Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to feed a complete table from a fragmented table with good performances

$
0
0

Hi,

I need to feed a complete Movements table from a fragmented one. In the complete Movements table I've a record for each year and month. In the fragemented table, from the OLTP system, I could have some combinations for year and month with no records.

In order to safeguard the performances, I think to run a first INSERT into complete Movements. Then, for each groups of data of the complete movements to get the last movement in order to assign the related data in the missing combinations of year and month, avoiding a loop if possible.

The following description says which result my proc should obtain:

Fragmented table

Mov_ID   Mov_Type   Mov_Center   Mov_Date      Year_Month

1              I               C_001           17/01/2013   201301

2             M               C_003           04/02/2013   201302

3             -                -                   -                  201303

4             -                -                   -                  201304

5             M               C_005           -                  201305

Completed table

Mov_ID   Mov_Type   Mov_Center   Mov_Date      Year_Month

1              I               C_001           17/01/2013   201301

2             M               C_003           04/02/2013   201302

3             M               C_003           04/02/2013   201303

4             M               C_003           04/02/2013   201304

5             M               C_004           11/05/2013   201305

Any suggests to me, please?

Below a picture representation:



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>