Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Thanks a lot Mate! I can't tell you how many times your site has saved my "rear". hehe..."

Geography

Where in the world do Tek-Tips members come from?

Trying to insert data from a table in another database

Baesucks (Programmer)
12 May 11 16:58
I'm trying to insert data into a table in my current database from a similar table in another database.  From inside my MS-Access ADP file I'm trying to do something like...

strSQL = "INSERT INTO [myTable] SELECT [theOtherTable].* FROM [TheOtherDatabase].[theOtherTable]"

DoCmd.RunSQL (strSQL)

Obviously, I will need to create a connection to the other database, but then how do I specify that in the SQL statement?
 
Baesucks (Programmer)
12 May 11 18:52
Never Mind.  I found out it can't really be done.  Had to create an MDB file and then link the tables from both databases to append records from one to the other.
PWise (Programmer)
13 May 11 9:54

CODE

strSQL = "INSERT INTO [myTable] SELECT [theOtherTable].* FROM [theOtherTable] IN 'Drive\path\myotherdb.mdb'"

or
sqlstr ="INSERT INTO [myTable] SELECT [theOtherTable].* FROM [theOtherTable]
IN '' [ODBC;DRIVER=SQL Server;SERVER=Servername;DATABASE=dbname]"
lameid (Programmer)
19 May 11 21:04
You could create a Linked Server in SQL Server in order to run a query across servers...  Most likely what you are doing is a one off and is perhaps more easily accomplished as you did linking both tables.

Any way the FQN for a table in another SQL server once you have linked it looks like...

[Server/Instance_Name].Database_Name.Schema_Name.Table_Name

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close