Solved

SELECT * INTO .. (to copy a table to SQL Server Database)

Posted on 2002-06-06
3
452 Views
Last Modified: 2012-06-21
I want to copy a table to a SQL Server database from an Access database using the query 'SELECT * INTO .. '
I have two DSNs. The source is Microsoft Access Driver and destination is SQL Server. I am executing this query in the context of Access DSN.

The query I used is: (which is not working)
SELECT * INTO [DSN=GG_SQLSrvr;DRIVER=SQL Server; UID=gg;PWD=****].[deviceinfo_dest] FROM [deviceinfo_src]

The error I am getting is "Could not find file 'C:\Uitls\DSN=GG_SQLSrvr'.

I set the select into/bulk copy option for the destination database in SQL serevr. (If I give a *.mdb file instead of the DSN string it’s working fine. But that’s not my requiremnt.)

1.What is the working query for this purpose? Even if the table 'deviceinfo_dest' does not exist I want to create it with the query.

Regards,
UnniC
mailto: unnic@procsys.com
0
Comment
Question by:unnic
3 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
I fear that this is not possible, at least i couldn't find an indication of that this could work...
CHeers
0
 
LVL 1

Expert Comment

by:johan_brohn
Comment Utility
Use OPENROWSET in SQL Server instead

SELECT *
INTO New_Table
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
   'C:\Dir\DB.mdb';'user';'password', Table)

OR (no username)

SELECT *
INTO New_Table
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
   'C:\Dir\DB.mdb';;, Table)

0
 
LVL 5

Accepted Solution

by:
spcmnspff earned 150 total points
Comment Utility
Actually, this is entirely possible. Your missing the letters 'ODBC;' in your connection string.  Try this one:


SELECT * INTO [ODBC;DSN=GG_SQLSrvr;DRIVER=SQL Server; UID=gg;PWD=****].[deviceinfo_dest] FROM [deviceinfo_src]

Otherwise Access assumes that the link is to another jet database . . .

 
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now