兩種方式查看:
一.
SQL_VARIANT_PROPERTY ( expression , property )
property :
1.BaseType SQL Server 數據類型
2.Precision 數值基本數據類型的位數
3.Scale 數值基本數據類型的小數點后的位數
4.TotalBytes 同時容納值的元數據和數據所需的字節數。 在檢查 sql_variant 列中數據的最大一側時,該信息很有用。 如果該值大於 900,則索引創建將失敗。
5.Collation 代表特定 sql_variant 值的排序規則。
6.MaxLength 最大數據類型長度(字節)。 例如,nvarchar(50) 的 MaxLength 是 100,int 的 MaxLength 是 4。
eg:
select sql_variant_property(ID,'BaseType')
sql_variant_property(ID,'Precision')
sql_variant_property(ID,'Scale')
from tb
二.
select object_name(ID)表名,
c.name 字段名,
t.name 數據類型,
c.prec 長度
from syscolumns c
inner join systypes t
on c.xusertype=t.xusertype
where objectproperty(id,'IsUserTable')=1 and id=object_id('tb')