views:

860

answers:

4

This should be simple. I'm trying to import data from Access into SQL Server. I don't have direct access to the SQL Server database - it's on GoDaddy and they only allow web access. So I can't use the Management Studio tools, or other third-party Access upsizing programs that require remote access to the database.

I wrote a query on the Access database and I'm trying to loop through and insert each record into the corresponding SQL Server table. But it keeps erroring out. I'm fairly certain it's because of the HTML and god knows what other weird characters are in one of the Access text fields. I tried using CFQUERYPARAM but that doesn't seem to help either.

Any ideas would be helpful. Thanks.

A: 

It's never advisable to loop through records when a SQL Update can be used.

It's not clear from your question what database interface layer you are using, but it is possible with the right interfaces to insert data from a source outside a database if the interface being used supports both types of databases. This can be done in the FROM clause of your SQL statement by specifying not just the table name, but the connect string for the database. Assuming that your web host has ODBC drivers for Jet data (you're not actually using Access, which is the app development part -- you're only using the Jet database engine), the connect string should be sufficient.

EDIT: If you use the Jet database engine to do this, you should be able to specify the source table something like this (where tblSQLServer is a table in your Jet MDB that is linked via ODBC to your SQL Server):

INSERT INTO tblSQLServer (ID, OtherField ) 
SELECT ID, OtherField
FROM [c:\MyDBs\Access.mdb].MyTable

The key point is that you are leveraging the Jet db engine here to do all the heavy lifting for you.

-- David W. Fenton http://dfenton.com/DFA/

David-W-Fenton
+1  A: 

Try using the GoDaddy SQL backup/restore tool to get a local copy of the database. At that point, use the SQL Server DTS tool to import the data. It's an easy to use, drag-and-drop graphical interface.

Chase Seibert
I tried this, but GoDaddy doesn't allow restores from anything but their own backups. I think they specialize in not doing things that every other web host in the known universe does.
+1  A: 

What error(s) get(s) thrown? What odd characters are you using? Are you referring to HTML markup, or extended (eg UTF-8) characters?

If possible, turn on Robust Error Reporting.

If the problem is the page timing out, you can either increase the timeout using the Admin, using the cfsetting tag, or rewrite your script to run a certain number of lines, and then forward to itself at the next start point.

Ben Doom
A: 

You should be able to execute saved DTS packages in MS SQL Server from the application server's command line. Since this is the case, you can use <cfexecute> to issue a request to DTSRUNNUI.EXE. (See example) This is of course assuming you are on a server where the command is available.

Andy Waschick