You are here: Re: MS SQL copy new and modified rows from TABLE1 to TABLE2 « MsSQL Server « IT news, forums, messages
Re: MS SQL copy new and modified rows from TABLE1 to TABLE2

Posted by Erland Sommarskog on 08/16/07 12:46

Yas (yasar1@gmail.com) writes:
> I have 2 tables, Table1 and Table2. I have copied all data from Table1
> to Table2.
> However Table1 is dynamic it has new rows added and some old rows
> modified everyday or every other day...
> How can I continue to keep Table2 up to date without always having to
> copy everything from Table1?
>
> Basically from now on I would only like to copy new rows or modified
> rows in Table1 to Table2 and skip rows that are already present and
> have not been modified in Table1. I would like to not do anything for
> any rows that were removed in Table1 and continue to keep a copy of
> them in Table2.
>
>
> Is using a DTS package the best way to automate this update of Table2
> to make sure Table2 is always up-to-date with Table1?

The first question is why do you want to do this in the first place? It
seems funny that you would want to have two identical tables in the same
database? Or ar the tables in different databases on different servers?

If the tables are on the same server, a trigger would be the best way
to do it.

If tbe tables are on different server, triggers are still possible, but
if the remote server is unavailable, this would cause the operation on
the source table to fail. In this case, replication may be a way to go.



--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация