Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Merging from an odbc source

Author  Topic 

anthonycampbell
Starting Member

4 Posts

Posted - 2008-03-12 : 13:40:57
Hi,

Im pretty new to SQL Server, but was able to create a dsn conenction to our dbf database, and then use sql script to import the table into sql server using this script below:

use cameodata;

/* Drop stock Table */
IF EXISTS (
SELECT 1
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'stock'
AND TABLE_SCHEMA = 'dbo'
AND TABLE_TYPE = 'BASE TABLE'
)
BEGIN
DROP TABLE stock
END

/* Import stock Table */
select * into stock
from openrowset ('msdasql','dsn=stock',
'select * from stock')


So basically everytime i run this script, it deletes the table in sql server and then imports the latest copy.

The problem is that this table is huge and it takes a while. What Id rather have is a script that i could run that would compare the dsn connected table with the table currently on sql server and if there are any updates then update sql server, if there are items on the sql server that are not the the latest copy, then delete that record on the sql server table and also if there are new items on the lastest copy then add the new record to the sql server table.

Is this possible?

thanks,
Anthony.
   

- Advertisement -