sqlserver 查询表字段类型

使用下面的SQL语句可以查询,SQLSERVER数据库表有哪些字段以及数据类型是什么
select column_name,
       case when NUMERIC_PRECISION is not null and (data_type='decimal' or data_type='numeric') then
                data_type+'('+cast(NUMERIC_PRECISION as varchar)+','+cast(NUMERIC_SCALE as varchar)+')'
            when  CHARACTER_MAXIMUM_LENGTH is not null then
                data_type+'('+cast(CHARACTER_MAXIMUM_LENGTH as varchar)+')'
            else
                data_type
       end as data_type,
       case when column_default IS null then ''
            else
              'DEFAULT  '+replace( replace(column_default,'(',''), ')','')
       end as defalutvalue,
       case when is_nullable='YES' then ''
            else 'NOT NULL'
       end as is_nullable
 from information_schema.columns
where table_name = 'AccountRecord'


阅读更多
版权声明:本文为博主原创文章,转载请注明出处http://blog.csdn.net/yh_zeng2 https://blog.csdn.net/yh_zeng2/article/details/52373799
个人分类: SQLSERVER
上一篇SQLSERVER获取排除了text类型的所有字段名以逗号隔开
下一篇Hive性能调优
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭