Is there any in built functions in SQL server to find whether the given value is i开发者_运维问答nteger or currency or date or decimal?
Well there is ISDATE() and ISNUMERIC(). What do you need to do?
If you're dealing with an SQL_VARIANT
, use the built-in SQL_VARIANT_PROPERTY
function:
SELECT SQL_VARIANT_PROPERTY(@value,'BaseType') AS 'Base Type'
There are no real inbuilt functions like you are looking for. The only option to determine is to query sysobjects, syscolumns and systypes (SQL 2000).
select
obj.name,
col.name,
typ.name
From dbo.sysobjects obj
Inner Join dbo.syscolumns col
On col.id = obj.id
Inner Join dbo.systypes typ
On typ.xusertype = col.xusertype
This query will list all tables with their columns and their types. Currency will be of type money, decimal is numeric. Within the columns table you can find the precision and scale of numeric.
精彩评论