I have a very simple query that looks at a large table of locations and returns details about specific street. I am trying to get high - low numbers to populate another single row and have elected to use a FUNCTION to do this
CREATE FUNCTION [dbo].[GetMaxStrNo]
(@StrFullName varchar)
RETURNS INT
AS
BEGIN
RETURN
(SELECT
MAX(CAST(apt_no AS INT))
FROM
location
WHERE
location_name = @StrFullName
AND ISNUMERIC(apt_no) = 1)
END
GO
Try as I might the results come back as NULL when called from my main procedure
SET @MaxStrNo = dbo.GetMaxStrNo (@StrFullName)
Any help would be most gratefully appreciated.
Many thanks