 |
| SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 28th, 2009, 05:14 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
I Have 2 SQL Sql Servers one is sql2000, the other sql2005.
SQL2000 is being updated every day, I Need this updates to be imported to sql2005
The way i try to do it is by running a Import Data Wizard on SQL 2005, after the wizard has finished importing data i see New record are addet to the database in sql 2005 instead of updating the existing ones.
Lets say SQL2000 database table1 has 5 records , i run the import data wizard and the 5 records are imported to SQL2005 database table1, now a new record is being inserted in sql2000, next time i run import wizard 6 records are being added to sql2005 so from 5 records it goes to 11
What i Need is a script that searches the database in sql2000 for any changes and imports them to SQL2005.
__________________
bx
Last edited by bex; June 28th, 2009 at 05:21 AM..
|
|

June 28th, 2009, 09:15 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
That happens because it is an "import wizard", it's not made to update the table every time you receive new info, you should be running it only once... Anyway, I don't understand how can I help you...
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|

June 28th, 2009, 11:36 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
can you point me in the right direction to pull only the updates...
also can Replication be Implemented between sql2000 and sql 2005?
__________________
bx
|
|

June 28th, 2009, 01:55 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
No, you will have to check out google to find the method that suits better for your scenery... I don't have a clue of what you have or what you need...
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|

June 28th, 2009, 02:07 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Bex,
You may want to get one of these two books:
http://www.wrox.com/WileyCDA/WroxTit...470247959.html
http://www.wrox.com/WileyCDA/WroxTit...764584359.html
They deal with Integration Services for SQL Server 2005 and 2008 and show you how to accomplish imports like this.
There are many ways to do what you need to do. A simple solution is to import all records in a temp table, then delete the ones from the original table that have a record in the temp table and then insert anything from the temp table to the destination table.
Integration Serives offers may other tasks that allow you to work on a row by row basis making it possible to do something like this:
IF EXISTS (SELECT FROM SomeTable WHERE Id = IdThatsBeingImported)
Update existing record
ELSE
Insert new record
END IF
You need a least a basic understanding of T-SQL and SQL Server to accomplish this; no wizards here.... ;-)
http://www.wrox.com/WileyCDA/WroxTit...764584340.html
http://www.wrox.com/WileyCDA/WroxTit...764543792.html
Cheers,
Imar
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

July 8th, 2009, 11:13 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
|
|
I managed to do this:
Code:
IF(EXISTS(SELECT AccountNumber
FROM SimOverride
AS t1
WHERE t1.AccountNumber ='G111'))
BeginSelect SLP05.CNAM05, SLP05.CUSN05 , SLP05.CAD205 , SimOverride.SimNet, SimOverride.Cost, SimOverride.Commission, SimDefault.SimNet, SimDefault.Cost, SimDefault.Commission From SimOverride CROSSJOIN
SLP05 CROSSJOIN
SimDefault
WHERE
(SLP05.CUSN05 ='G111')
End
Else
BeginSelect
SLP05.CNAM05, SLP05.CUSN05, SLP05.CAD205, SimDefault.SimNet, SimDefault.Cost, SimDefault.Commission FROM SimDefault CROSSJOIN SLP05 Where(SLP05.CUSN05 ='G111')
End
But this Selects every thing from SimDefault and Sim Override, What i need is Select what is in SimOverride then go to SimDefault and get All minus what it took from SimOverride.
The else Is OK ,
Thanks for looking
__________________
bx
|
|

July 8th, 2009, 12:57 PM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
|
|
bex:
When I join tables, I have a higher success rate using either a RIGHT or LEFT Joins. Could you send the scheme layouts of the tables depicting their Primary Keys and Foreign Keys, not the entire layout? I think I can get the "to-be"Table from previous posts.
__________________
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.
|
|
 |