Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi..
Im Working On Some 'X' Project, It is Running From Last 6 Years, Now I Want To Split Data Into Two Data Base. i.e 2009 to 2012 Data In one Db & from 2013 to another Database
Plz Help.. Thanks In Advance.
Posted
Updated 13-Mar-14 19:46pm
v2

How I would do it:

backup and restore the Db to another Db - so one becomes the 'old' and one the 'new'

identify the transactional tables

write sql to delete by date, < in one Db and >= in the other.

This assumes that you have some sort of transaction date on the transactional data, of course!
 
Share this answer
 
Comments
Tharun@Chinna 14-Mar-14 2:04am    
HI Maxxx,
IN My Db I have 100+ transactional Tables, is Any Alternative to Delete Data with 1 Query, Instead Of Writing Delete Query Foe Each Table. i.e Parent Table X is There. Before Deleting Data from 'X' Table I have to delete Data from All Child Tables, Is it Possible To Delete data from All Parent And Child tables Data At A time..
_Maxxx_ 14-Mar-14 7:24am    
If there is a 'dateupdated' column on every table, for example, you could use sp_foreachtable to run 'delete from ? where fromdate < @thedateyouwant
This will fail for referenced tables, but you can just keep running it until it gets rid of everything.
A brute force approach - but should work if you have a consistent method of identifying records on every table.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900