zoukankan      html  css  js  c++  java
  • 表值类型生成

    declare @TableType varchar(max) =''
    declare @tablename varchar(max)
    set @tablename='student'
     
    select @TableType=@TableType
        +case when types.name in ('varchar','nvarchar','char','nchar','varbinary')
              then '['+columns.name+']'+' '+types.name+'('
                   +cast(columns.max_length as varchar)+')'+','+char(13)
              else case when types.name in ('numeric','decimal')
                        then '['+columns.name+']'+' '+types.name+'('
                             +cast(columns.max_length as varchar)+','
                             +cast(columns.scale as varchar)+')'+','+char(13)
                        else '['+columns.name+']'+' '+types.name+','+char(13)
                   end
         end
      from sys.columns
        join sys.objects
        on columns.object_id=objects.object_id
        join sys.types
        on columns.user_type_id=types.user_type_id
      where columns.object_id=object_id(@tablename)
     
     
    print 'CREATE TYPE '+@tablename+'Type AS TABLE
    ('++char(13)+left(@TableType,len(@TableType)-2)+char(13)+')'

  • 相关阅读:
    最后之作-Last Order(bushi
    Hydra's plan
    CSP-S2019游记
    题解 P1407
    初赛排序知识
    题解 洛谷P3469
    二分图网络流知识总结
    题解 SGU294 He's Circles
    noip复习——逆元
    noip复习——线性筛(欧拉筛)
  • 原文地址:https://www.cnblogs.com/qanholas/p/2482153.html
Copyright © 2011-2022 走看看