I'm trying to create a stored function called func_GetMenuItemsForMenu.
For this function, I need to pass the ID of the menu to it. The function will find all MenuItems that are on the menu. It will return a table.
Here is what I have tried:
CREATE FUNCTION [dbo].[func_GetMenuItemsForMenu]
(@MenuItemMenuItemID NVARCHAR(200))
RETURNS TABLE
AS
RETURN (SELECT Menu.MenuID
FROM Menu, MenuItem
WHERE MenuItem.MenuID LIKE @MenuItemMenuItemID + '%'
AND MenuItem.MenuID = Menu.MenuID)
GO
Here is my table structure:

I'm only getting the MenuID and it's not returning the menu item as well that's on the specific menu.
SELECTlist.... you should also use explicit joins. Your old-style join has really, really old.selectstatement. Only the columns listed betweenselectandfromwould be returned. ChangeSELECT Menu.MenuID FROM Menu...toSELECT Menu.MenuID, MenuItem.MenuItemTitle FROM Menu...or what ever column you want to return.