none
Designing query in Editor - Linking tables from other database in design mode

    Question

  • How does one add tables to a Query editor from different databases? I can see tables in the object explorer window on the left side but cant see the table when I try work in design mode. Please help

    What I actually want is to add tables from diffrent databases to query editor by using Add Table ... window.

    Thanks and Regards

    Dr. Hasan Bhutta

    Wednesday, September 11, 2013 2:17 PM

Answers

All replies

  • Use a synonym to create a local object that points to the table in the remote database.  This is a general best-practice for cross-database queries and it enables the query designer.  eg

    create database a
    create database b
    go
    use a
    create table t(id int)
    go
    use b
    create table u(id int)
    create synonym t for a.dbo.t

    David


    David http://blogs.msdn.com/b/dbrowne/

    Wednesday, September 11, 2013 2:25 PM
  • You  can do it with Drag & Drop from other databases to the design mode of query or view. 

    The most important motivation for the research work that resulted in the relational model was the objective of providing a sharp and clear boundary between the logical and physical aspects of database management. - E. F. Codd
    Saeid Hasani's home page

    • Proposed as answer by Saeid Hasani Wednesday, September 11, 2013 2:32 PM
    Wednesday, September 11, 2013 2:29 PM
  • You can Drag & Drop to the View design window, but the query design window is a modal popup so you can't drag tables onto it from the object explorer (at least in SSMS 2012).

    David


    David http://blogs.msdn.com/b/dbrowne/

    Wednesday, September 11, 2013 3:24 PM