这是从园里一位大哥那里拷来的代码,有时候还是非常管用的,原来T-SQL也是可以查询到变量的类型的,我真汗~~~~
PRINT CAST(SQL_VARIANT_PROPERTY(20, 'BaseType') AS VARCHAR(50)) PRINT CAST(SQL_VARIANT_PROPERTY(0.1, 'BaseType') AS VARCHAR(50)) PRINT CAST(SQL_VARIANT_PROPERTY(20 / 0.1, 'BaseType') AS VARCHAR(50)) DECLARE @a nvarchar(10) SET @a = N'Hello World' SELECT @a, CAST(SQL_VARIANT_PROPERTY(@a, 'BaseType') AS VARCHAR(50))