• 得到数据库中所有表的列数方法


    <!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->

     

     

    -- 得到数据库中所有表的列数方法

     

    declare    xcursor   cursor    for

    select    name    from    sysobjects   where    xtype= 'u'

    declare    @name   varchar ( 100)

    open    xcursor

    fetch    xcursor   into    @name

    create    table    #temptable   ( tablename varchar ( 300), rowcount1   int )

    while    @@fetch_status = 0

    begin

    exec ( 'insert   into   #temptable   select   ''' + @name+ ''',count(*)   from   ' + @name)

    fetch    xcursor   into    @name

    end

    close    xcursor

    deallocate    xcursor

     

    select    b. name, count ( a. name)    as    列数 from    syscolumns   a, sysobjects   b   , #temptable   c

    where    b. xtype= 'u'    and    a. id= object_id ( b. name)    and    b. name= c. tablename

    group    by    b. name

    drop table #temptable

     

  • 相关阅读:
    spring揭密学习笔记(3)-spring ioc容器:Spring的IoC容器之BeanFactory
    spring揭密学习笔记(3)-spring ioc容器:掌管大局的IoC Service Provider
    spring揭密学习笔记(2)-spring ioc容器:IOC的基本概念
    spring揭密学习笔记(1) --spring的由来
    spring揭密学习笔记
    spring事务管理实现原理-源码-传播属性
    spring事务传播实现源码分析
    IDEA搭建Spring框架环境
    ScrollView滑动的监听
    Android对apk源代码的改动--反编译+源代码改动+又一次打包+签名【附HelloWorld的改动实例】
  • 原文地址:https://www.cnblogs.com/Gaojier/p/2783546.html
Copyright © 2020-2023  润新知