Solved

SQLServer Merge Statement when new column is added

Posted on 2016-07-22
2
60 Views
Last Modified: 2016-07-23
Hi,

  I'm planning on implementing a Change Data Capture on one of the files, we get. We get this file every week.
This file is a fixed length file and it gets loaded into our database. Since the volume of the file is large, we are planning on doing a full load for the first time, and the following load on wards, use the incremental load. We have analyzed the Merge statement for the Type-2 changes and wanted to implement it.

Now, the issue i got is that, this fixed length file may get new fields every month.
How can we utilize the merge command with respect to the schema changes and not loose any of the CDC data captured till then?

Please advise.
0
Comment
Question by:pvsbandi
2 Comments
 
LVL 16

Accepted Solution

by:
DcpKing earned 500 total points
ID: 41725983
CDC and the Merge command are different things. CDC creates a history of what has happened to the data in your table, whereas the Merge command is your choice of how to achieve the changes to that data.

The CDC works on tables, and should adapt automatically if you make changes by adding fields to those tables - which it sounds like you'll be doing.

The Merge command works down at the field level, so if you get new fields in your incoming data you'll not only have to add them to your (CDC-aware and other) tables but also you'll have to change the resultant commands that your code obeys as a result of a match condition in a Merge statement.

You may be able to write the Merge statement as dynamic SQL, but you'll still have to change table structures for the tables the data ends up in. It sounds like you'll have a monthly release schedule!!

Just a couple of refs for you about CDC - Intro and Overview and Other Features. The first is a great intro.

Hope this helps

Mike
0
 

Author Closing Comment

by:pvsbandi
ID: 41726131
Clear now. Thank you!
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question