title: SQL server Function and procedure regarding the linking of a table output to scalar procedure
body: <p>This what I have so far individually all for sections work fine, I just cant figure out how to combine them properly.
  Table function and procedure</p>
  
  <pre><code>USE [MENUdb]
  GO
  
  
  
  CREATE Function [dbo].[func_GetMenuItemsForMenu]
  (
  @MENUID NVARCHAR (50)
  )
  RETURNS TABLE
  AS
  RETURN
  (
  SELECT MenuItem.MenuID,MenuItem.MenuItemID,MenuItem.MenuItemTitle FROM MenuItem,Menu
  WHERE Menu.MenuID = @MENUID 
  AND MenuItem.MenuID = Menu.MenuID)
  GO
  
  USE [MENUdb]
  GO
  
  
  ALTER Procedure [dbo].[sp_GetMenuItemsForMenu]
  (
  @ENTER_MENUID int
  )
  
  AS
  BEGIN
  SELECT * FROM func_GetMenuItemsForMenu (@ENTER_MENUID)
  END
  </code></pre>
  
  <p>Scalar function and procedure</p>
  
  <pre><code>USE [MENUdb]
  
  
  ALTER FUNCTION [dbo].[func_GetMenuItemDescriptionForMenuItemID]
  
  (
  @MENUITEMID int
  )
  
  RETURNS nvarchar(MAX)
  AS
  BEGIN
  RETURN 
  (
  SELECT  MenuItem.MenuItemTitle +'  ' + MenuItem.MenuItemDescriptionText FROM MenuItem WHERE MenuItemID = @MENUITEMID
  )
  END
  
  
  USE [MENUdb]
  GO
  
  
  ALTER Procedure [dbo].[sp_GetMenuItemDescriptionForMenuItemID]
  
  (
  @ENTER_MENUITEMID int
  )
  
  AS
  BEGIN
  SELECT dbo.func_GetMenuItemDescriptionForMenuItemID (@ENTER_MENUITEMID)
  END
  </code></pre>
  
  <p>Individually they work fine exactly as they should besides the fact that I am not sure how to output if there are multiple rows that fit the input for the scalar</p>
  
  <p>My main issue is that I can quite figure out how to get the result of the Table function specifically the MenuItemID column to work as the input of the Scalar function</p>
  
  <p>what should happen is this, say there are 3 items on menu 1, I enter 1 in the initial execution and it returns the 3 items IDs and Names in table form, how do I pass the IDs in the MenuItemID column to the next function?</p>
  
  <p>Coding is not my strong point so im probably missing something very simple...</p>