Drop the constant recurring JOINs in SQL queries on a SQL-Server, is this possible?



  • I would like to show the columns of "linked" tables in SQL-Server database.
    In my particular case, there are two tables "Loads" and "Locations", linked by Loads.LocationId=Locations.Id.

    I just to work for a company, based on Oracle DB technology, which used the following notation (simple example):

    DB_Name.show, Loads.Name, Locations.Name
    

    Thas was called GCC or TOC, according to the version. As you see, the link between both tables is not mentioned.

    I realise this is not common notation, and now I'm working for an SQL-Server based company, using basic SQL.
    In order to show the same data, I need to write something like:

    SELECT Loads.Name, Locations.Name FROM Loads, Locations
    WHERE Loads.LocationId = Locations.Id
    

    /* I know it's not a good idea to use a WHERE-clause for a join, /
    /
    but that's not the point here. */

    As you can imagine, the tables are set up in such a way that the mentioned join is always applicable, so I'm wondering if there might be a way to configure my database in such a way that I don't always need to mention the WHERE (or JOIN clause), every time I write an SQL query.

    Is this possible?
    Thanks in advance



  • I'm afraid that there's no NATURAL JOIN or any other language element so you don't have to specify the join condition in MSSQL. (I wish that exists...)

    As an aside, if you stick to the old join syntax, you won't be able to do OUTER JOINs in MSSQL. (I know you didn't ask for this, but thought I'd mention this part anyhow...)




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2