Solved

sql server replication

Posted on 2012-03-29
3
210 Views
Last Modified: 2012-06-21
I want some way of doing replication in which only inserted and updated data gets replicated not the deleted one.

The idea is to build archiving database from the live db. but we want live db to be small.

1- Move changed data from live db to archive db
2- delete data from live db of older than today

we have to implement this in sql server. any other solution than replication.
0
Comment
Question by:Epurchase
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
lojk earned 50 total points
ID: 37782264
Your best option is to use triggers added to your tables.

http://msdn.microsoft.com/en-us/library/ms189799.aspx

also

http://msdn.microsoft.com/en-us/magazine/cc164047.aspx

After each 'Insert/Update' trigger you coudl write to another table in another database (if required) based on the values that were changed from the current row (that the trigger provides to you)  and then flush transactions from the bottom of your current table as required (or overnight using an SQL Agent Scheduled Task stored procedure).

The topic of triggers is too complicated to go into here - you will just need to go and read up about it but be warned you will almost certainly need to learn about stored procedures too (if you are not already familiar with them) as without them things get very complicated quite quickly.
0
 
LVL 1

Author Comment

by:Epurchase
ID: 37785818
Is there any way we can achieve the same using replication? I know the trigger option but wanted to do somehow using replication.
0
 
LVL 9

Expert Comment

by:lojk
ID: 37785900
Well, your original question ends..

"have to implement this in sql server. any other solution than replication."

Other than replication and using triggers, what else is there? clr doesn't supply any option that tsql doesn't already provide either.

I understand what you are trying to achieve I have done similar things too - using triggers, you could probably do something using a bunch of half baked client side code but it won't work (as well)

Have fun with this.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

744 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

13 Experts available now in Live!

Get 1:1 Help Now