TSQL确定参数是否为结构化类型

时间:2016-05-24 07:29:25

标签: sql-server tsql

我正在使用此过程来确定存储过程的参数类型。

select  
    'Parameter_name' = name,  
    'Type' = type_name(user_type_id),  
    'Length' = max_length,  
    'Prec' = case 
                when type_name(system_type_id) = 'uniqueidentifier' 
                   then precision  
                else OdbcPrec(system_type_id, max_length, precision) 
             end,  
    'Scale' = OdbcScale(system_type_id, scale),  
    'Param_order' = parameter_id,  
    'Collation' = convert(sysname, 
                case when system_type_id in (35, 99, 167, 175, 231, 239)  
                then ServerProperty('collation') end)  
from 
    sys.parameters 
where 
    object_id = object_id('MySchema.MyProcedure')

但是如果参数是表值,那么我得到类型的名称。

如何确定它是否为“结构化”类型?

1 个答案:

答案 0 :(得分:0)

如果您查询Private listItem1() As String Private listItem2() As String Private Sub Combo1_Click() Dim intCount As Integer Combo2.Clear If Combo1.ListIndex = 0 Then For intCount = LBound(listItem1) To UBound(listItem1) - 1 Combo2.AddItem listItem1(intCount), intCount Next intCount ElseIf Combo1.ListIndex = 1 Then For intCount = LBound(listItem2) To UBound(listItem2) - 1 Combo2.AddItem listItem2(intCount), intCount Next intCount End If Combo2.ListIndex = 0 End Sub Private Sub Form_Load() Combo1.AddItem "Item list 1", 0 Combo1.AddItem "Item List 2", 1 ReDim listItem1(2) ReDim listItem2(2) listItem1(0) = "Apple" listItem1(1) = "Orange" listItem2(0) = "Book" listItem2(1) = "CD Desk" Combo1.ListIndex = 0 End Sub sys.table_types,则可以查看数据库中的所有表格类型:

sys.types

您可以看到SELECT * FROM sys.table_types; SELECT * FROM sys.types WHERE is_table_type = 1; 对于所有表类型都是相同的。您可以将其解压缩并在查询中使用。另一种方法是将上述信息存储在表变量或临时表中,并将其(LEFT JOIN)连接到system_type_id