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.
| Author |
Topic |
|
tracmonali
Starting Member
16 Posts |
Posted - 2012-05-19 : 10:02:04
|
| can somebody help me understand how is this alias for the select stmt diff than a temp table? would putting in a temp table be an optimal solution?Scenario1:select * from tabl1inner join ( select * from table 3 inner join table 4 on table3.col1 = table4.col1) AliasNameon AliasName.col4 = tabl1.col1Scenario2Create table #tempAliasName (col1, col2, col3, col4)insert into #tempAliasName(select * from table 3 inner join table 4 on table3.col1 = table4.col1)select * from tabl1inner join #tempAliasNameon #tempAliasName.col4 = tabl1.col1Please help me understand the diff between 2 scenarios (wrt optimization, good querying practice, overhead on server) if any? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2012-05-19 : 13:00:44
|
[code]SELECT *FROM dbo.Table1 AS t1INNER JOIN dbo.Table3 AS t3 ON t2.Col4 = t1.Col1INNER JOIN dbo.Table4 AS t4 ON t4.Col1 = t3.Col1[/code] N 56°04'39.26"E 12°55'05.63" |
 |
|
|
tracmonali
Starting Member
16 Posts |
Posted - 2012-05-20 : 10:45:03
|
quote: Originally posted by SwePeso
SELECT *FROM dbo.Table1 AS t1INNER JOIN dbo.Table3 AS t3 ON t2.Col4 = t1.Col1INNER JOIN dbo.Table4 AS t4 ON t4.Col1 = t3.Col1 N 56°04'39.26"E 12°55'05.63"
there is no selection from table2?????? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-05-20 : 11:23:43
|
quote: Originally posted by tracmonali
quote: Originally posted by SwePeso
SELECT *FROM dbo.Table1 AS t1INNER JOIN dbo.Table3 AS t3 ON t2.Col4 = t1.Col1INNER JOIN dbo.Table4 AS t4 ON t4.Col1 = t3.Col1 N 56°04'39.26"E 12°55'05.63"
there is no selection from table2??????
there's no table2 in your example ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|