• 表结构查询 Sql


    select row_number() over(order by a.column_id) rownumber, a.name, 
    case
    when t.name in (N'decimal', N'numeric') then t.name + '('+ Convert(varchar(10),a.precision) + ',' + Convert(varchar(10),a.scale) +')'
    when t.name in (N'varchar', N'nvarchar', N'char', N'nchar') then t.name + '('+ Convert(varchar(10),a.max_length) +')'
    else t.name end
    data_type,
    case a.is_nullable when 1 then 'Y' else 'N' end is_nullable,
    case a.is_identity when 1 then 'Y' else '' end is_identity,
    isnull(def.text,N'') defalut_value,
    isnull(ft.name + '.' + fc.name,N'') foreig_key,
    isnull(ep.value,N'') [description]
    from sys.columns a
    left join sys.types t on t.user_type_id = a.user_type_id
    left join sys.syscolumns sc on sc.id = a.object_id and sc.colid = a.column_id
    left join sys.syscomments def on def.id = sc.cdefault
    left join sys.foreign_key_columns fkc on fkc.parent_object_id = a.object_id and fkc.parent_column_id = a.column_id
    left join sys.columns fc on fc.object_id = fkc.referenced_object_id and fc.column_id = fkc.referenced_column_id
    left join sys.tables ft on ft.object_id = fkc.referenced_object_id
    left join sys.extended_properties ep on ep.major_id = a.object_id and ep.minor_id = a.column_id and ep.name = N'MS_Description'
    where exists(select 1 from sys.tables b where b.object_id = a.object_id and b.name = N'表名称')
  • 相关阅读:
    nohup 命令的使用
    Linux下完全删除用户
    free命令详解
    Nginx页面不能访问排查思路
    netstat命令详解
    VMware Workstation工具给liunx创建共享磁盘
    yum命令使用小技巧
    Linux 常用命令-- top
    ssh免密访问对端服务
    Java根据IP获取地区(淘宝接口)
  • 原文地址:https://www.cnblogs.com/itstac/p/10819822.html
Copyright © 2020-2023  润新知