I recall, I was just curious how someone else was doing it with simple SQL.
You of all people should know there are quite a few ways to skin the
neighbors cat and duct tape it to the light pole outside.

On 11/21/05, Andrew Tyrone <[EMAIL PROTECTED]> wrote:
>
> > -----Original Message-----
> > From: Aaron Rouse [mailto:[EMAIL PROTECTED]
> > Sent: Monday, November 21, 2005 11:04 AM
> > To: CF-Talk
> > Subject: Re: Multiple Row Insert Into SQL from another database
> >
> > I am curious what would the SQL script look like to connect
> > to the MS Access
> > and then insert into the current MSSQL db? I do not work with
> > MSSQL enough
> > to know so just curious how simple it is.
>
> As you'll recall, we were chatting about this the other day. Since I
> already had code to connect to an Access DB from a previous project (which
> was linked to FoxPro tables -- yecch!), I modified it a bit to work with a
> new project that needs data imported from an Access DB to SQL Server. The
> way I went about it is to create a linked server in SQL Server, using an
> OLEDB Jet 4.0 connection to Access:
>
> <cfquery ...>
> USE Master
>
> <!--- Drops the linked server if it exists already --->
> EXEC sp_dropserver mylinkedserver, droplogins
>
> EXEC sp_addlinkedserver
> @server = 'mylinkedserver',
> @provider = 'Microsoft.Jet.OLEDB.4.0',
> @srvproduct = 'Microsoft OLE DB Provider for Jet',
> @datasrc = '[absolute_path_to_mdb_file]'
>
> EXEC sp_addlinkedsrvlogin accessdbname, FALSE, username, password
> </cfquery>
>
>
> <cfquery ...>
> <!--- Extract data from the access db and into SQL Server. This creates
> the
> tables in sql server as well --->
> SELECT *
> INTO [tablename]
> FROM linkedservername...[tablename]
> </cfquery>
>
>
> To transform the data using native Access functions, you can use SQL
> Server's OPENQUERY() function:
>
> <cfquery ...>
> <!--- Extract data from the access db and into SQL Server --->
> SELECT
> DOB
>
> INTO
> tablename
>
> FROM
> OPENQUERY
> (mylinkedserver,
> SELECT
> IIF(YEAR(DOB)<1753 OR
> YEAR(DOB)>9999,NULL,DOB) AS DOB
> FROM
> tablename
> )
> </cfquery>
>
>
>
> -- Andy
>
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:224905
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to