Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
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
 
Old June 28th, 2009, 05:14 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

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..
 
Old June 28th, 2009, 09:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

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.
================================================== =========
 
Old June 28th, 2009, 11:36 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

can you point me in the right direction to pull only the updates...

also can Replication be Implemented between sql2000 and sql 2005?
__________________
bx
 
Old June 28th, 2009, 01:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

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.
================================================== =========
 
Old June 28th, 2009, 02:07 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
bex (June 28th, 2009)
 
Old July 8th, 2009, 11:13 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

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
 
Old July 8th, 2009, 12:57 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default

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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Join tables help tdaustin Classic ASP Databases 2 January 11th, 2006 04:57 PM
how to join all records from both tables? yixchen Access 4 January 4th, 2006 01:36 PM
how to inner join tables gilgalbiblewheel Classic ASP Databases 4 January 31st, 2005 08:04 PM
Join Tables tdaustin Classic ASP Basics 1 May 25th, 2004 07:31 AM
Inner Join multiple tables qwprince Classic ASP Databases 5 July 23rd, 2003 02:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.