title: SQL Server passing table columns to a function's parameter
body: <p>I have an SQL function which returns the minimum and maximum selling price of an item. I'd like to make a query which gets other StockItem columns together with it's selling price</p>
  
  <p>like so: </p>
  
  <pre><code>SELECT i.StockItemID ii, 
         i.Name, 
         i.Code, 
         pli.SellingPrice AS MinSellingPrice,
         pli.StandardSellingPrice AS MaxSellingPrice,
         i.WebDetailedDescription,
         i.WebAdditionalInfo,
         i.FeaturedItemDescription
  FROM SC_StockItem AS i, 
       func_GetPrice(17, i.StockItemID, 5) pli
  </code></pre>
  
  <p>However this gives an error: </p>
  
  <blockquote>
    <p>Msg 4104, Level 16, State 1, Line 12 The multi-part identifier
    "i.StockItemID" could not be bound.</p>
  </blockquote>
  
  <p>any idea how I can do this ?</p>
  
  <p>Thanks in advance</p>