Transact-SQL does not offer a good way to support
constants in your stored procedures or userdefined functions. This means that you either can choose to hardcode your constants or, the more elegant way, define a userdefined function for each "constant" value. To ensure optimal performance, the
schemabinding keyword should be used.
Here is an example:
CREATE FUNCTION [dbo].[sudf_Security_Privilege_User]
(
)
RETURNS INT
with schemabinding
AS
BEGIN
-- Return the access level
RETURN (1);
END
In your stored procedure you can call the function the normal way, i.e.
set x = dbo.sudf_Security_Privilege_User();