A "Delta" migration is necessary when you migrate some data now and some data later.
If you want to copy the Result_Ids for all tables, simply use the query below.
- use [PHASE1_DB]
- exec sp_MSforeachtable '
- UPDATE
- [PHASE2_DB].?
- SET
- Comment = Phase1.Comment,
- Batch_Number = Phase1.Batch_Number,
- Batch_Group = Phase1.Batch_Group,
- Status_ReferenceCode = Phase1.Status_ReferenceCode,
- Status_Description = Phase1.Status_Description,
- Status_Date_From = Phase1.Status_Date_From,
- Status_Date_Till = Phase1.Status_Date_Till,
- Result_Id = Phase1.Result_Id,
- Result_ReferenceCode = Phase1.Result_ReferenceCode
- FROM
- [PHASE1_DB].? Phase1,
- [PHASE2_DB].? Phase2
- WHERE 1=1
- and Phase1.Id = Phase2.Id
- and Phase2.Result_Id = ''''
- '
Or if you want to copy the Result_Ids for one specific table, use the query below:
- USE [PHASE2_DB]
- UPDATE
- [PHASE2_DB].dbo.__M_Matters
- SET
- Comment = Phase1.Comment,
- Batch_Number = Phase1.Batch_Number,
- Batch_Group = Phase1.Batch_Group,
- Status_ReferenceCode = Phase1.Status_ReferenceCode,
- Status_Description = Phase1.Status_Description,
- Status_Date_From = Phase1.Status_Date_From,
- Status_Date_Till = Phase1.Status_Date_Till,
- Result_Id = Phase1.Result_Id,
- Result_ReferenceCode = Phase1.Result_ReferenceCode
- FROM
- [PHASE1_DB].dbo.__M_Matters Phase1,
- [PHASE2_DB].dbo.__M_Matters Phase2
- WHERE 1=1
- and Phase1.Id = Phase2.Id
- and Phase2.Result_Id = ''