March 13, 2013 at 8:59 am
Hi,
I'm looking for a basic example of a temporary table joined to and actual table
I'm guessing it should be like:
Select Model
FROM CARS INNER JOIN #tempTable on
CARS.Model = #tempTable.Model
March 13, 2013 at 9:02 am
Exactly the same as a join between two normal tables. Yes, your example is completely correct.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
March 14, 2013 at 12:50 am
TJT (3/13/2013)
Select ModelFROM CARS INNER JOIN #tempTable on
CARS.Model = #tempTable.Model
This query will give you an error about Model being an ambiguous column in the SELECT list
Hence, It is always a good idea to use aliases
SELECTC.Model
FROMCARS AS C
INNER JOIN #tempTable AS T ON C.Model = T.Model
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply