DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Work with different databases in VB 6.0 and SQLServer 2000

  1. #1
    Pablo Guest

    Work with different databases in VB 6.0 and SQLServer 2000


    In Visual Basic 6.0 and SQL Server 2000 I Want make
    "Insert Into TableA Select * From TableA, TableB Where TableA.CodTa1 = TableB.CodTa2"

    How I can do it, if TableA is in different database of TableB.

  2. #2
    DaveSatz Guest

    Re: Work with different databases in VB 6.0 and SQLServer 2000

    If they are on the same server, we would create a view in database called
    like:

    create view vw_tableb
    as
    select *
    from databaseb..tableb
    go

    and then:

    Insert Into TableA
    Select *
    From TableA a
    JOIN vw_TableB b ON a.CodTa1 = b.CodTa2

    one thing to note is that the user of the view ag. database B created in
    database a must be a valid user in database B as well as database a.


    --
    Thanks,
    David Satz
    Principal Software Engineer
    Hyperion Solutions
    ->Using SQL Server 7.0 SP2/6.5 SP5a/Cold Fusion 4.5.1/ADO 2.1/VB 6.0/MTS
    (Please reply to group only)
    -----------------------------------------------------------------

    "Pablo" <programacion@grupocci.com> wrote in message
    news:3a3a1e69$1@news.devx.com...
    >
    > In Visual Basic 6.0 and SQL Server 2000 I Want make
    > "Insert Into TableA Select * From TableA, TableB Where TableA.CodTa1 =

    TableB.CodTa2"
    >
    > How I can do it, if TableA is in different database of TableB.




  3. #3
    Michael Levy Guest

    Re: Work with different databases in VB 6.0 and SQLServer 2000

    In addition to Dave's answer, I would expect that referencing the table with
    the database qualifier would work:

    INSERT INTO tablea
    SELECT *
    FROM TableA ta INNER JOIN Database2..TableB tb ON ta.CodTa1 = tb.Codtb2

    This assues that tableb is owned by DBO. If not, you'll have to specify the
    table owner: database2.owner.tableb

    -Mike
    --
    Michael Levy MCDBA, MCSD, MCT
    michaell@gasullivan.com



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center