Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2006
    Posts
    4

    Unanswered: Simply link from two tables

    Hi all,

    I would like to simply link two tables that are in two different databases in the SAME server.
    I know that I could use the replication method (snapshot or merge) but I need a simpler method like the Access link table method.

    Any suggestions?
    Thanks
    Alessandro

  2. #2
    Join Date
    Jan 2005
    Location
    Green Bay
    Posts
    201
    select * from database.owner.table1
    join database.owner.table2

    ...

  3. #3
    Join Date
    Jun 2006
    Posts
    4
    sorry, I was not clear.

    "link" means that the two tables must be syncronized. Must have the same contents.

  4. #4
    Join Date
    Jan 2006
    Location
    USA
    Posts
    115
    SELECT database1.dbo.table1.column1, database2.dbo.table2.column2

    FROM database1.dbo.table1 JOIN database2.dbo.table2

    ON database1.dbo.table1.column1 = database2.dbo.table2.column2

    assume database1, database2, column1, table2 as a symbol for this example, put your own database name, table, column according to your requirement.

    You can specify list of columns you wants or you can use asterisk (* symbol) for all columns...

  5. #5
    Join Date
    Jan 2006
    Location
    USA
    Posts
    115
    Quote Originally Posted by alecava
    sorry, I was not clear.

    "link" means that the two tables must be syncronized. Must have the same contents.
    Yeah, you are right. It could be possible that SQL Server has more than one database with different name, but having same contents.

  6. #6
    Join Date
    Jun 2006
    Posts
    4
    I can do that database1.users and database2.users have a permanent link so that the contents of the first table is always the same of the second table (insert, modify and delete)?

    Thanks

  7. #7
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    Another method would be a triggers on the source table for the appropriate functions on the destination table.

    But my question would be why in the world you would want to do that? With SQL Server, you can use the same table in queries from other databases by using the 3-part name (database.owner.tablename).

    -- This is all just a Figment of my Imagination --

  8. #8
    Join Date
    Dec 2004
    Posts
    46
    try to create a view :
    create view db2..view_of_table1
    as
    select * from db1..table1
    go

  9. #9
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Quote Originally Posted by alecava
    sorry, I was not clear.

    "link" means that the two tables must be syncronized. Must have the same contents.

    TRUNCATE TABLE database1.dbo.table2
    GO

    INSERT INTO database2.dbo.table1 (Col1, col2, col3....)
    SELECT Col1, Col2, Col3
    FROM database1.dbo.table1
    GO


    If you want realtime, use TRIGGERS
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •