A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
You can use join clause in SQL to get the desired results.
https://learn.microsoft.com/en-us/sql/relational-databases/performance/joins?view=sql-server-ver15