例如,假设我有一个视图:
CREATE VIEW [dbo].[PaymentSchedule_vw] AS SELECT [Order].Id [Order Id],[PaymentSchedule].Date [Payment Date] FROM _Order123 [Order] INNER JOIN _Order123_Shedule [PaymentSchedule] ON [Order].Id = [PaymentSchedule].OrderId GO
如何发现[订单ID]和[付款日期]的类型?
解决方法
SELECT c.name,t.name,c.max_length,c.precision,c.scale FROM sys.columns c JOIN sys.types t ON t.user_type_id = c.user_type_id AND t.system_type_id = c.system_type_id WHERE object_id = OBJECT_ID('PaymentSchedule_vw')
或者您可以使用sql_VARIANT_PROPERTY – some examples here.