Join table and view from different databases on same SQL 2005 server

  • Database1 has table, database2 has view.

    view contain select data from table_n.

  • Database1 has table, database2 has view.

    view contain select data from table_n.

    E.g

    Database1: Table1

    Database2: View1

    and if you are on Database1 Server

    then,

    Use following syntax

    select * from Table1 t

    join [Database2].dbo.View1 t2

    on t1.col=t2.col

    You can add whatever columns you need there...

    Let us know if this is not what you needed.

    -RP

    -RP
  • Database1 has table1, database2 has view.

    view contain select data from table_n. The both database are on the same server.

    E.g

    Query is:

    on database1

    insert into table2 select * from database2.dbo.view

    select * from Table1 t

    join table t2

    on t1.col=t2.col

    From QA I got results, but from VB I got empty grid.

    Stored procedure stopped on insert step from VB.

  • Ensure that you are calling your procedure on correct database (check connection string).

    Since you are using VB; avoid any "On Error Resume Next"/"On Error GoTo 0". Check if you get any exceptions.

  • Check your insert operation first before proceeding to the Join...

    Check if your table2 has data in it or not???

    -RP
  • Gordana.Lazic (6/5/2009)


    From QA I got results, but from VB I got empty grid.

    Stored procedure stopped on insert step from VB.

    Hi,

    Check the user permission in the DB1/DB2 and for the table1/2

    ARUN SAS

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply