I am simply trying to return the count(*) integer value that is produced from the select. This is my first attempt at functions.
I have tried my inner statements out of the function and all works as I expect. This returns the table, but what I really want is just to return an integer of what the count(*) returns. How can I do this?
CREATE FUNCTION dbo.LogicMatchCount
(@logic varchar(1000),
@tags varchar(1000)
)
RETURNS TABLE
AS
RETURN
WITH
LogicTagTable AS
(
SELECT TRIM(VALUE) AS logic_tag
FROM string_split(@logic, '&')
),
DonorTagTable AS
(
SELECT TRIM(VALUE) donor_tag
FROM string_split(@tags, ',')
)
SELECT COUNT(*) AS TagMatchCount
FROM LogicTagTable ltt
INNER JOIN DonorTagTable dtt ON dtt.donor_tag = ltt.logic_tag;
Thanks!