Selecting data from two databases within MSSQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • teju
    New Member
    • Jul 2006
    • 34

    Selecting data from two databases within MSSQL

    Hello,
    I would like to know whether is it possible to select data from two different databases within the same sql server.
    For example
    I have one database as StudentList which is the central database for students and i have other database as courseselection

    i want to select the student no from the student list database and enter the course selection in the course selection database.

    Could some one advice me whar would be the optmistic way of doing it

    Regards,
    Teju.
  • helloiamhere
    New Member
    • May 2007
    • 5

    #2
    Originally posted by teju
    Hello,
    I would like to know whether is it possible to select data from two different databases within the same sql server.
    For example
    I have one database as StudentList which is the central database for students and i have other database as courseselection

    i want to select the student no from the student list database and enter the course selection in the course selection database.

    Could some one advice me whar would be the optmistic way of doing it

    Regards,
    Teju.
    Ya It is possible
    Query to get the studentno and the course selected

    select StudentList.dbo .[tablename].student no, CourseSelection .dbo.[tablename].courseselected from StudentList.dbo .[tablename],CourseSelectio n.dbo.[tablename]

    Comment

    • teju
      New Member
      • Jul 2006
      • 34

      #3
      Originally posted by helloiamhere
      Ya It is possible
      Query to get the studentno and the course selected

      select StudentList.dbo .[tablename].student no, CourseSelection .dbo.[tablename].courseselected from StudentList.dbo .[tablename],CourseSelectio n.dbo.[tablename]

      It throws an error back
      StudentList object name not found.

      Thanks

      Comment

      • almaz
        Recognized Expert New Member
        • Dec 2006
        • 168

        #4
        The query posted by helloiamhere is just a sample of how you should refer to different databases.
        StudentList and CourseSelection are DATABASE names

        Comment

        • helloiamhere
          New Member
          • May 2007
          • 5

          #5
          Originally posted by teju
          It throws an error back
          StudentList object name not found.

          Thanks

          Ofcourse the another reply defines the solution. For the details you posted i gave a sample query...

          just try the same with the database you have in your server.

          Comment

          Working...