Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / May 2008

Tip: Looking for answers? Try searching our database.

Insert between separate databases

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John - 17 May 2008 03:45 GMT
Hi

I have an insert sql that inserts selected records from one table into
another. Is there a way to specify in the insert statement that one table is
from one database and the second table is from another database i.e. insert
is between tables of two separate databases?

Thanks

Regards
Frans Bouma [C# MVP] - 17 May 2008 09:51 GMT
> Hi
>
> I have an insert sql that inserts selected records from one table into
> another. Is there a way to specify in the insert statement that one table is
> from one database and the second table is from another database i.e. insert
> is between tables of two separate databases?

    depends on the database system used. If you use sqlserver, and you have
both catalogs in the same server, you can do:
INSERT INTO [cataloga].[schemaowner].[table] (field1, field2,...)
SELECT field1, field2, ...
FROM [catalogb].[schemaowner].[table]
where...

    schemaowner is usuablly 'dbo'

    If they're on separate boxes, you can link one server into another
server. You then get yet another name in front of the table name:
..
FROM [server].[catalogb].[schemaowner].[table]...

        FB

Signature

------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

John - 17 May 2008 14:58 GMT
One is a local access database (i.e. on the same box as the .net code being
run on), the other is a remote sql server which I can access via ip address.
Am I doomed?

Thanks

Regards

>> Hi
>>
[quoted text clipped - 18 lines]
>
> FB
Frans Bouma [C# MVP] - 18 May 2008 10:34 GMT
> One is a local access database (i.e. on the same box as the .net code being
> run on), the other is a remote sql server which I can access via ip address.
> Am I doomed?

    No :).
    You can link the remote sqlserver database inside access if I'm not
mistaken, as a set of tables.

    Which data is merged into which one btw? Access into sqlserver?

        FB

> Thanks
>
[quoted text clipped - 19 lines]
>> ..
>> FROM [server].[catalogb].[schemaowner].[table]...

Signature

------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

John - 18 May 2008 14:22 GMT
Both ways unfortunately. Thanks

Regards

>> One is a local access database (i.e. on the same box as the .net code
>> being run on), the other is a remote sql server which I can access via ip
[quoted text clipped - 31 lines]
>>> ..
>>> FROM [server].[catalogb].[schemaowner].[table]...
Paul Clement - 19 May 2008 16:27 GMT
¤ Both ways unfortunately. Thanks
¤

Yes, you can insert rows from a table in one database to a table in a different database.

So are you inserting rows from one table that are not present in the other? Do each of the tables
have primary keys or is there some other criteria by which the insert should occur?

Paul
~~~~
Microsoft MVP (Visual Basic)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.