views:

69

answers:

1

is it possible for a udf to return the same data type as one of its parameters?

i would like my udf to accept a decimal of any precision and scale and return the same type.

+1  A: 

You can make the function accept and return a sql_variant.

Andomar
i need to use the round function so i need a decimal
Ben
You can use SQL_VARIANT_PROPERTY(colA,'Precision') to retrieve the precision of the variant http://msdn.microsoft.com/en-us/library/ms178550.aspx Then you can use a CASE statement to treat cast different variants in a different way.
Andomar