Solved

SQLServer Merge Statement when new column is added

Posted on 2016-07-22
2
50 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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
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.

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now