Temp table join example

  • 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

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • TJT (3/13/2013)


    Select Model

    FROM 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


    Kingston Dhasian

    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