Solved

SQLServer Merge Statement when new column is added

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
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 extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

729 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