Results 1 to 3 of 3

Thread: How to reference a table in a different database?

  1. #1
    Join Date
    Apr 2006
    Posts
    1

    How to reference a table in a different database?

    I have 2 databases in sql server. let us say database1 = db1 and database2 = db2
    Now both the databases have a same table called table1 with the same fields.

    IF data in db1.table1 is updated then data in db2.table2 should be updated automatically.

    There are many ways we can do this. one way is to create a INSERT trigger on db1.table1.

    But i would like to avoid trigger
    Is there something in SQL server where I can just link table1 of db1 to db2 and delete the table1 in db2. That means db2 is using the same table that of db1.

    Thanks

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    No, can't do that. Why need that table in db2? You can query tables in db1 from db2 like:

    select * from db1.owner.table where ...

  3. #3
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    create transactional replication from table1 to table2.

Posting Permissions

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