|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
i want to replicate the data from one table into another table in the same database,all the transactions in table "a" should be replicated in table "b" and vice versa.
Note:this should be done without using triggers |
|
#2
|
||||
|
||||
|
A view?
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins |
|
#3
|
|||
|
|||
|
hi,
Thanks for u r reply, can u just elaborate ![]() |
|
#4
|
|||
|
|||
|
well, could you elaborate a bit more??? You want the exact same data in 2 diff tables?? There are numerous ways to do this, if we know how, when, and why this is needed maybe we can select the best way for you.
|
|
#5
|
|||
|
|||
|
detailed requirement
Ok,
We r doing the stratification of a module in a project , for which we have to change the design of a table which is used by other modules so we thought of creating another table for this module ,but we want to synchronize the data betwen both the tables,one solution is to write triggers on both the tables. Is there any others solution. Pls help me |
|
#6
|
|||
|
|||
|
so it sounds like this is a temporary ordeal?
Not sure when, how, and why the table is populated, but why not just add code to update the other table as well? To start out, just create another table and dump what's in the orig table into the new one, then add code to simply INSERT any new data into the new table as well? Just use a flag variable to detect records that were the most recently inserted. If it's a temporary thing that's one thing I would consider. |
|
#7
|
|||
|
|||
ThanksBut i dont think this is he solution. May be the detail explaination i gave was not so clear , i'll try to explain it in detail. Suppose there is a table Guest which is used by 5 modules, now we r working on the first module where we find that some of the columns r redundant or we need to add some more columns to the table.Now because we r working only on the first module we do not want to make changes to original table because that may effect other modules so we make another say guestnew. So the new table will be updated by the new module only and the original table will be used by all the other modules. Whenever one table is updated the other table also has to be updated . |
|
#8
|
||||
|
||||
|
I would check if it's possible to:
1. add another table holding the new columns 2. build a view joining the two tables 3. use that view in your module instead of the original tables (SQLServer supports updateable views with some restrictions) |
|
#9
|
|||
|
|||
|
That solution would work if we could change all the modules at the same time ,but the problem is that it has been decided to take up one module at a time i.e the code in other modules will be left untouched.
Now to use a view its name would have to be the same as the original table which is not possible ,renaming the original table also is not possible because it is linked to many other tables. so if u have any oher solution pls revert back immediately Pls this is urgent |
|
#10
|
|||||||
|
|||||||
|
Why can't do that?
You wrote: Quote:
I'm not suggesting to modify the original one Quote:
I'm suggesting to make a new table, holding only the new attributes (columns) and the appropriate keys, then build a view that joins the original table and the new one and use that view in your module Quote:
that's why I'm suggesting an updateable view Quote:
that's what my suggestion hopes to achieve Quote:
that's why I'm suggesting to use a view, you'll see all the modifications made by the other modules seamlessly integrated with the ones from the new module. Hope I clarified my suggestion (again not all views are updateable, check it first). |
|
#11
|
|||
|
|||
Thanks a lot for ur help.I think the solution u gave will solve my problem.Thanks again |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > How do i replicate a table in the same database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|