Home > Software design >  How do you pass a column value to a function that returns a table
How do you pass a column value to a function that returns a table

Time:01-31

I have a stored procedure that takes an int and returns a table that's used in a left join. I'd like to create a view instead of calling the procedure. Is there any way to do this? I'm getting "multi-part identifier couldn't be bound"

Example:

select users.*, extended.* 
from users left join dbo.getaggregateproperties(users.Id) as extended
on users.userid = extended.extendedid

CodePudding user response:

Use CROSS APPLY instead

SELECT users.*, extended.*
FROM users
CROSS APPLY dbo.getaggregateproperties(users.Id) as extended
WHERE users.userid = extended.extendedid
  •  Tags:  
  • tsql
  • Related