易截截图软件、单文件、免安装、纯绿色、仅160KB

数据字典(SQL语句)

declare @tmp table
(
id int identity(1,1),
TableName varchar(100),
Column_name varchar(100),
Type varchar(50),
Lenght int,
Scale int,
Nullable varchar(1),
Defaults varchar(4000),
PrimaryKey varchar(1)
)
select iid = identity(int,1,1), * into #a from SysObjects where xtype = 'U'
declare @i int
declare @max int
declare @table varchar(100)
set @i = 1
select @max = max(iid) from #a
while @i <= @max
begin
    select @table = name from #a where iid = @i
    if @@rowcount > 0
    begin
        insert @tmp (TableName, Column_name, Type, Lenght, Scale, Nullable, Defaults,PrimaryKey)
        select @table, a.name, c.name, a.length, a.xscale, case a.isnullable when 0 then 'N' else 'Y' end, isnull(d.text,''), case when x.PrimaryKey is null then '' else x.PrimaryKey end
        from SysColumns a with(nolock)
        inner join (select * from SysObjects with(nolock) where xtype = 'U' and  id = object_id(@table)) b on a.id = b.id
        inner join SysTypes c with(nolock) on a.xtype = c.xusertype
        left join syscomments d with(nolock) on a.cdefault = d.id
        left join
            (select f.id, colid, 'Y' as PrimaryKey from SysIndexKeys f with(nolock), SysIndexes e, SysObjects g
            where f.id = e.id and f.indid = e.indid and f.id = g.parent_obj and e.name = g.name
            and g.xtype = 'PK' and g. parent_obj = object_id(@table)) x on a.id = x.id and a.colid = x.colid
    end
    set @i = @i + 1
end
select * from @tmp


相关文档:

航空公司管理系统(VC++ 与SQL 2005)

系统环境:Windows 7
软件环境:Visual C++ 2008 SP1 +SQL Server 2005
本次目的:编写一个航空管理系统
      这是数据库课程设计的成果,虽然成绩不佳,但是作为我用VC++ 以来编写的最大程序还是传到网上,以供参考。用VC++ 做数据库设计并不容易,但也不是不可能。以下是我的程序界面,后面 ......

研究生成SQL脚本

IF   OBJECT_ID('DataAsInsCommand')   IS   NOT   NULL   DROP   PROC   DataAsInsCommand  
  GO  
  SET   QUOTED_IDENTIFIER   OFF  
  GO  
  CREA ......

三种SQL分页法

三种SQL分页法
   表中主键必须为标识列,[ID] int IDENTITY (1,1)
  1.分页方案一:(利用Not In和SELECT TOP分页)
语句形式:  
SELECT TOP 10 *
from TestTable
WHERE (ID NOT IN
          (SELECT TOP 20 id
     ......

SQL Server数据库优化

[摘要] 缺省情况下建立的索引是非群集索引,但有时它并不是最佳的。在非群集索引下,数据在物理上随机存放在数据页上。
优化数据库的注意事项:
  1、关键字段建立索引。
  2、使用存储过程,它使SQL变得更加灵活和高效。
  3、备份数据库和清除垃圾数据。
  4、SQL语句语法的优化。(可以用Sybase的SQL E ......

【转】SQL优化 索引

微软的SQL SERVER提供了两种索引:聚集索引(clustered index,也称聚类索引、簇集索引)和非聚集索引(nonclustered index,也称非聚类索引、非簇集索引)……
<script type="text/javascript"></script>
  (一)深入浅出理解索引结构
  实际上,您可以把索引理解为一种特殊的目录。微软的SQ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号