SQL: How can I run this query?
I am the following selection statement in a stored procedure to get data from a table, with one of the columns using a function that returns a JSON. I am having trouble writing the query properly. The function GetRecordComments requires two parameters, with the first one being the RecordID of each row. When I use this query though, I get the following error. How can I call the function with the recordID for each row. My query: SELECT RercordID, Name, Region, dbo.GetRecordComments((Select RecordID from RecordList where RecordID = a.RecordID), 1), [Address],dbo.GetRecordComments((Select RecordID from RecordList where RecordID = a.RecordID), 2)FROM RecordList AS a Error: "Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression."