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

SQL使用小结

1. 如果你希望使用selcet top语句,并且还要附带where条件,那么条件中的列就得是合适的索引,如聚集索引、复合索引里的主列
 等,同时,where条件里也要尽量避开使用函数,or,判断NULL等会引起全部扫描的语句,不然执行的是全表扫描。
2. 通过设置STATISTICS我们可以查看执行SQL时的执行效率以及相关性能测试。选项有PROFILE,IO ,TIME。
例:SET STATISTICS PROFILE ON 
      SET STATISTICS IO ON 
      SET STATISTICS TIME ON 
      GO /*--你的SQL脚本开始*/
      SELECT * from [TableName] 
      GO /*--你的SQL脚本结束*/
      SET STATISTICS PROFILE OFF 
      SET STATISTICS IO OFF 
      SET STATISTICS TIME OFF


相关文档:

用sql写小计和合计

select case when b.name is null and c.name is null then '合计' when b.name is null and c.name is not null then '小计' else b.name end as mtrname,
sum(a.number),c.name as cname from x_sell a join x_material b on a.mtr=b.fid join p_organi c on c.fid=a.customer
where a.stime>'2009-10-01'
GROUP B ......

自增字段的SQL语句解决方案

 create table [表名]
(
[自动编号字段] int IDENTITY (1,1) PRIMARY KEY ,
[字段1] nVarChar(50) default '默认值' null ,
[字段2] ntext null ,
[字段3] datetime,
[字段4] money null ,
[字段5] int default 0,
[字段6] Decimal (12,4) default 0,
[字段7] image null ,
)
删除表:
Drop t ......

用SQL语句得到SQLServer 的表中的列的描述值

 select   case   when   c.colid=1   then   object_name(c.id)   else   ''   end   as   表名    
  ,c.name   as   字段名  
  ,t.name   数据类型  
  ,c.prec   as   长度   ......

PB 数据库连接以及sql语句运行信息返回代码解释大全


如果一个 SQL 语句发生了错误,那么 sqlca.sqlcode 将是非零值。
如果 sqlca.sqlcode 小于 0 那么就是发生了某种严重的错误,象数据库定义与查询定义不一致等.
如果大于 0 则是通常的错误,象表不包括所要求的行等.
sqlca.sqlcode == 0,成功
sqlca.sqlcode == -1 失败     (获取具体失败信息 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号