易截截图软件、单文件、免安装、纯绿色、仅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


相关文档:

提高 SQL 性能的方法

有时, 为了让应用程序运行得更快,所做的全部工作就是在这里或那里做一些很小调整。啊,但关键在于确定如何进行调整!迟早您会遇到这种情况:应用程序中的 SQL 查询不能按照您想要的方式进行响应。它要么不返回数据,要么耗费的时间长得出奇。如果它降低了报告或您的企业应用程序的速度,用户必须等待的时间过长,他们就会 ......

sql server2005转库至sql server2000

1、先导出数据到ACCESS,再导到sql server2000,出现问题,字段类型被改变。
2、采用 生成sql server脚本 解决问题。
SQL Server 2005数据库文件转到SQL Server 2000的步骤
1. 生成for   2000版本的数据库脚本  
  2005   的manger   studio  
  --&nb ......

SQL数据库修复命令

SQL数据库修复命令
2007-12-23 16:49
MS Sql Server 提供了很多数据库修复的命令,当数据库质疑或是有的无法完成读取时可以尝试这些修复命令。
1. DBCC CHECKDB
重启服务器后,在没有进行任何操作的情况下,在SQL查询分析器中执行以下SQL进行数据库的修复,修复数据库存在的一致性错误与分配错误。
use master
decla ......

SQL Server和Oracle的常用函数比较

---------数学函数 ---------------
  1.绝对值
  S:select abs(-1) value
  O:select abs(-1) value from dual
  2.取整(大)
  S:select ceiling(-1.001) value
  O:select ceil(-1.001) value from dual
  3.取整(小)
  S:select floor(-1.001) value
  O:select floor(-1.001) value from ......

有用的sql语句

  随机读取若干条记录,测试过
Access语法:SELECT top 10 * from 表名 ORDER BY Rnd(id)
Sql server:select top n * from 表名 order by newid()
mysql select * from 表名 Order By rand() Limit n
  说明:选择从10到15的记录
select top 5 * from (select top 15 * from table order by id asc) table_别名 or ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号