I am working on a function that will be used by no less than 10 SProc's, and will probably grow once it is ironed out.
Problem i am running into is that i do not want to develop a function for each Data Type, which is why the SQL_VARIANT
data type is looking pretty convenient for the action. I know is can do the ISNULL
check on the data type but i also want to check to see if the Value being passed is a valid Number but the ISNUMERIC
function does not work with SQL_VARIANT
and I'm not too sure about the SQL_VARIANT_PROPERTY
function.
Code so far:
CREATE FUNCTION dbo.mpt_Format_Number
(
@value SQL_VARIANT
, @money BIT
)
RETURNS VARCHAR
AS
BEGIN
--Check for NULL value
IF ISNULL(@value) BEGIN
-- Value IS NULL, return NULL
RETURN NULL
END ELSE BEGIN
-- Value is NOT NULL
DECLARE @TMP VARCHAR
END
END