zoukankan      html  css  js  c++  java
  • SQL Server表结构打印

    declare @t table(表名 varchar(100),字段名 varchar(100),数据类型 varchar(100),长度 varchar(100),描述 sql_variant )
    declare @table varchar(100),@counter int,@tablecount int,@talben varchar(100),@a varchar(100),@b varchar(100),@c varchar(100),@d varchar(100),@e varchar(100)
    select @tablecount=count(name) from sysobjects where xtype='u'
    declare tablen cursor for
    select name from sysobjects where xtype ='U'
    open tablen
    set @counter=1
    while @counter<@tablecount
    begin
      fetch next from tablen
      into @talben
      insert @t SELECT  表名=case when a.colorder=1 then d.name else '' end,
    字段名=a.name,
    类型=b.name,
    长度=COLUMNPROPERTY(a.id,a.name,'PRECISION'),
    字段描述=isnull(g.[value],'')
    FROM syscolumns a
    left join systypes b on a.xtype=b.xusertype
    inner join sysobjects d on a.id=d.id  and d.xtype='U' and  d.name<>'dtproperties'
    left join syscomments e on a.cdefault=e.id
    left join sysproperties g on a.id=g.id and a.colid=g.smallid 
    left join sysproperties f on d.id=f.id and f.smallid=0
      where d.id=object_id(@talben)
      order by a.id,a.colorder
      --insert @t select @talben

    set @counter=@counter+1
    end
    close tablen
    deallocate tablen
    select * from @t
    用前台控件显示再打印。

  • 相关阅读:
    sprint2(第九天)
    sprint2 (第八天)
    sprint2(第七天)
    sprint2(第六天)
    sprint2(第四天)
    sprint2(第三天)
    sprint2(第二天)
    sprint 2(第一天)
    0621 第三次冲刺及课程设计
    0617 操作系统实验4 主存空间的分配和回收
  • 原文地址:https://www.cnblogs.com/digjim/p/459883.html
Copyright © 2011-2022 走看看