Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Tables

Author  Topic 

aroraaj
Starting Member

2 Posts

Posted - 2014-03-27 : 11:35:07
Hello Everyone,

I am trying to work on a SQL Server 2008 project. I have two tables named History and Last Quarter. The last quarter has the current data. The logic that I have right now is that the data from last_quarter backups to the history table and then last_quarter get truncated and new data is entered. However, I am looking for an option when I backup to history table I don't want any duplicate records. Does anyone know how this can be approached?

Thanks!

sqlsaga
Yak Posting Veteran

93 Posts

Posted - 2014-03-27 : 11:39:33
You can achieve this using MERGE.. It's like moving from source to destination. Follow the article I wrote on merge, if you have anyother questions feel free to ask...

http://sqlsaga.com/sql-server/how-to-capture-changes-between-source-and-destination-using-merge-statement/

Visit www.sqlsaga.com for more t-sql snippets and BI related how to's.
Go to Top of Page
   

- Advertisement -