4

I need to edit old-styled T-SQL code.

  • What does =* mean?

  • What does *= mean?

I think, that they are JOIN, but I don't know, what JOIN type is each of them.

3
  • Those are outer joins
    – user330315
    Nov 28, 2015 at 9:15
  • And what is difference between of them?
    – Arthur
    Nov 28, 2015 at 9:16
  • 3
    One is a left join the other a right join. See the manual for details msdn.microsoft.com/en-us/library/…
    – user330315
    Nov 28, 2015 at 9:18

1 Answer 1

5

I found answer!

-- Example 1: Deprecated syntax for an inner join
SELECT [T2].[c3], [T1].[c3] 
FROM [dbo].[Table2] T2, [dbo].[Table1] T1 
WHERE [T1].[ID] = [T2].[ID]

-- Example 2: Current syntax for an inner join
SELECT [T2].[c3], [T1].[c3] 
FROM [dbo].[Table2] AS T2
INNER JOIN [dbo].[Table1] as T1
ON [T2].[ID] = [T1].[ID]

-- Example 3: Deprecated syntax for a left outer join
SELECT [T2].[c3], [T1].[c3] 
FROM [dbo].[Table2] T2, [dbo].[Table1] T1 
WHERE [T1].[ID] *= [T2].[ID]

-- Example 4: Fixed syntax for a left outer join
SELECT [T2].[c3], [T1].[c3] 
FROM [dbo].[Table2] AS T2
LEFT OUTER JOIN [dbo].[Table1] as T1
ON [T2].[ID] = [T2].[ID]

-- Example 5: Deprecated syntax for a right outer join
SELECT [T2].[c3], [T1].[c3] 
FROM [dbo].[Table2] T2, [dbo].[Table1] T1 
WHERE [T1].[ID] =* [T2].[ID]

-- Example 6: Fixed syntax for a right outer join
SELECT [T2].[c3], [T1].[c3] 
FROM [dbo].[Table2] AS T2
RIGHT OUTER JOIN [dbo].[Table1] as T1
ON [T2].[ID] = [T2].[ID]

https://msdn.microsoft.com/en-us/library/dd172122(v=vs.100).aspx

1
  • 3
    There are obvious typos here: [T2].[ID] = [T2].[ID]. MSDN is not perfect. Nov 28, 2015 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.