Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQLServer Merge Statement when new column is added

Posted on 2016-07-22
2
Medium Priority
?
78 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
DcpKing earned 2000 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

721 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