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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 A strange cross join

Author  Topic 

theboyholty
Posting Yak Master

226 Posts

Posted - 2011-07-18 : 05:40:47
I know that cross joins aren't very often used and are to be handled as you would milk a porcupine - i.e. very carefully, but I came across a stored proc in one of our databases where it wasn't coded as I would expect.

Normally you'd expect something like
SELECT fields
FROM table1
CROSS JOIN table2


. . but this one was written thus:

SELECT fields FROM table1,table2


I can't tell if its lazy code or clever code or whether it makes no difference at all (certainly the result is identical). I'd value your opinions.

---------------------------------------------------------------------------------
http://www.mannyroadend.co.uk The official unofficial website of Bury Football Club

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2011-07-18 : 05:46:50
Its the ANSI Standard way of writing joins. When it comes to T-SQL, it is just lazy coding, the compiler currently deals with both the same way, but who knows whether it will in the future (get your crystal balls out)..
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-07-19 : 05:44:12
As said, ANSI standard is the difference. There can be other methods too like this

SELECT fields FROM table1 as t1 inner join table2 as t2 on 1=1


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -