t-sql udf,获取一个参数的数据类型 [英] t-sql udf, get the data type of a parameter
本文介绍了t-sql udf,获取一个参数的数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以为我的 udf 获取数字参数并根据其类型执行操作,例如:
is it possible to get a numeric parameter to my udf and do stuff according to its type, like:
如果@p1 的类型是十进制(10,3)...否则如果@p1 的类型是十进制(15,3)...否则如果@p1 的类型是整数...
if type of @p1 is decimal(10,3) ... else if type of @p1 is decimal(15,3) ... else if type of @p1 is integer ...
推荐答案
试试 sql_variant_property 函数...
Try out the sql_variant_property function...
一些例子...
Declare @Param Int
Set @Param = 30
Select sql_variant_property(@Param, 'BaseType')
Select sql_variant_property(@Param, 'Precision')
Select sql_variant_property(@Param, 'Scale')
Declare @ParamTwo float
Set @ParamTwo = 30.53
Select sql_variant_property(@ParamTwo, 'BaseType')
Select sql_variant_property(@ParamTwo, 'Precision')
Select sql_variant_property(@ParamTwo, 'Scale')
希望对您有所帮助:)
这篇关于t-sql udf,获取一个参数的数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文