Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Views across databases in SQL management Studio

Author  Topic 

Dubzzz
Starting Member

8 Posts

Posted - 2012-07-10 : 10:40:14
Hi all,

I am very new to SQL, as have been introduced recently by a colleague and we are both facing an issue with the server management which we couldn't find an answer on any forums.

As we do not know much of it so far, we have created tables and views to sort out most of our requirements ( which is closer to access basic functionalities than extended SQL server management). We are using Microsoft SQL management studio 2008 R8.

I would like to know if there is any possibility to create views which refer to other databases (e.g. DB2)than the one it is created in (e.g DB1), all this in the very nice and useful diagram area? I cannot so far bring the tables (from this other DB2) in and link it to the one in DB1?
I have understood I can do this in a query, but I loose here the diagram functionality which is so friendly for beginners?

Any thought?

Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-10 : 10:43:23
yep. you can create views to refer other databse tables so long as DB is in same server containing your primary db. You need to refer the other db tables as otherdbname.schema.tablename

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Dubzzz
Starting Member

8 Posts

Posted - 2012-07-10 : 10:56:40
Hi Visakh16,

Many Thanks for your answer. I see you refer to the code here (otherdbname.schema.tablename)... Does that mean that I cannot make it happen by dragging the table via the diagram functionality?

Sorry to be so new to this..
Go to Top of Page

Dubzzz
Starting Member

8 Posts

Posted - 2012-07-10 : 11:03:31
Sorry I got it!!

Thanks very much...

For the other beginners... just input after SELECT what visakh16 suggetsed (otherdbname.schema.tablename), in the code area and the table will appear in the diagramm area... then just need to link as another table

GREAT support. thanks again visakh16
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-10 : 12:30:09
you're welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -