Scalar functions are usually a performance problem because they execute row by row. The best option for performance when you need parameters is an inline table valued function which is written like thisÑ
CREATE FUNCTION hstore_num ()
RETURNS TABLE
AS
RETURN
SELECT TOP 1 'Highest Store Count' = COUNT(state)
FROM stores
GROUP BY state
ORDER BY 'Highest Store Count' DESC;
GO
Of course, with no parameters, you could use a view instead
CREATE VIEW hstore_num
AS
SELECT TOP 1 'Highest Store Count' = COUNT(state)
FROM stores
GROUP BY state
ORDER BY 'Highest Store Count' DESC;
GO
Both of them would be called as a table, but the function needs to use parenthesis.
SELECT *
FROM hstore_num() --
Hope this is clear.