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
 Use C# to import Access tables into SQL Server

Author  Topic 

sami022
Starting Member

11 Posts

Posted - 2010-03-10 : 17:13:41
Hi



I have to import some Access 2003 tables into a SQL Server 2005. Since I have to do this every 6 months (different Access db into same SQL-Server) and since I have to check every single row I can't do it with the import data wizzard. I need to import the access tables into "temporary" tables in sql server and from there I'll put the rows into the correct tables...



Does anyone know how to import Access tables into SQL-Server 2005 with C#?



Thank you for your help!

SAMI

hi every body!

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-03-11 : 04:03:19
I'm a little confused about your c#-requirement...why do you need c# to process the data? Can't you just import the access data in to a temporary table in the sql server using the wizard and then process the temporary table using a suitable sql query?

Pseudo-code

INSERT INTO tmpMyAccessData
SELECT * FROM OPENROWSET(...access-connection...)

INSERT INTO myProductionTable
SELECT
CAST(Col1 AS int),
CAST(Col1 AS datetime),
...
FROM tmpMyAccessData


- Lumbago
If the facts don't fit the theory, change the facts. Albert Einstein
Go to Top of Page
   

- Advertisement -