How to query the database using field from a @Tmp table

  • Good morning everyone. I know that this is a very dumb question, but I have a list of names stored into a @Tmp table. I want to take that list of names and then query the database using the name field as key to a record called description, and extract all of the descriptions.

    Thanks.

    G

  • Could you explain in more detail please?

    "Query the database" - what table name?

    "name field as key to a record called description" - are both Name and Description columns in a table?

    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
  • Hi. The @Tmp table has only one field called sku. I want to read sku and link it to

    the record called dbo.SFC_ItemURL on dbo.SFC_ItemURL.Item = sku and extract the dbo.SFC_ItemURL.Description so that I end up with a list of sku and description. Thank you for your help.

    G.

  • SELECT iu.Item, iu.Description

    FROM dbo.SFC_ItemURL iu WHERE Item IN (SELECT t.sku FROM @Tmp t)

    Edit: I broke my own rule to always qualify column names 🙁

    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
  • Thanks so much, I will give that a try right now.

  • That worked great, thank you so very much.

    G.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply