SSMS has a query designer, which I usually avoid, because honestly, I can't really work with it.
Unfortunately, my colleagues do. As I have 30 minutes to spare, I finally want to know whether I am the problem or SSMS.
For example: Let's assume we have a table buildings, a table floors, a table rooms and a mapping table usage_types (room-usage_types).
When I design the query manually, i do this:
select all buildings,
left join all floors in those buildings
left join all rooms in those floors
left join the room-usage_types mapping table.
Now, when I try to do the same in query designer, it somehow starts with the mapping table, then left joins the rooms, left joins the floors, and then left joins the buildings.
Which is fundamentally flawed, because if there is no entry in the mapping table for a room, it will not return all rooms (this is assuming every room is necessarely in a floor, and every floor is necessarely in a building, but not every room has necessarely a usage-type associated with itselfs [for a certain period of time])...
Now, if I start to modify the joins I get this query
SELECT
FROM usage_type mapping
RIGHT OUTER JOIN Floors
LEFT OUTER JOIN Rooms
RIGHT OUTER JOIN Floors
Now this query seems equivalent, but this is an example, and usually, i have to join many more tables. So I don't particularly like the mix of right and left joins, because it's hard to understand in the end (especially when several ON statements don't follow at the place where the join is made), making the search for bugs near impossible (and I don't have much trust into query designer's ability to figure out what I want).
I have so far not found a way to 'design' the query like i want. The only way seems to be to create the initial query, then get the SQL text, then adjust the joins, and then reopen this with SQL query designer.
Needless to say that in the end, this takes longer than doing it manually in the first place, and when the SQL script was modified by the query designer, you can't read it anymore without reformatting it first by hand...
It seems to me that my variant is utterly impossible to accomplish with query designer ... What I find peculiar as well is that in the query designer, in the context menu of the join symbol, sometimes the table to the left is on top, and sometimes, the table to the right.
And then, when I have to select the lower one instead of the upper one, it does a right join. I can choose the upper one, then it does a left join, but in the wrong sequence... which is exactly what I don't want...
So I wanted to ask: Is there some 'secret' way of specifying from which table the query shall start, preferably without any right joins at all ?