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

查询mssql大批量数据

数据库内有500W条数据,查询的时候如何优化
这段时间也在看SQL.我觉得这两本书不错!SQL艺术,SQL2008技术内幕 T-SQL基础.

确实写一条高效的SQL不是容易的事!我记得最清楚的一条是:最近过滤掉不符合条件的记录

500W.......这个结果谁看的完.
sql语句复杂的话,建议用存储过程. 优化明确精确的数据结果进行查询.

select distinct jixing,guige,danwei,zhuanhuanbi,shengchanqiye,tongyongming from bi_zhongbiaobiaozhunhua as m2 where exists (select id from bi_tongyong as m1 where m1.id=m2.tongyongming and exists (select tongyongname from bi_tongyong where tongyongname=m1.tongyongname and exists(select id from bi_shengchanqiye where id=bi_tongyong.shengchanqiye and shengchanqiye like'%神威药业%')) and shengchanqiye not in (select id from bi_shengchanqiye where shengchanqiye like '%神威药业%')) order by tongyongming desc
这样的一条语句,我已经在表中建了索引

这样的语句如何优化?


相关问答:

MSSql数据库被挂马

现有一个ASP+mssql的网站,被挂马了,将里面一个表中的ntext字段挂马挂马,“<script src=http://木马地址></script>”,的方式是,不断地修改该字段的值,直接加在最后的,时间长了,可以看到该字段中有 ......

两部MSSQL服务器不能互连能否采用离线文件同步?

请问MSSQL是否支持离线文件的发布和订阅?比如生成同步文件后再复制到要同步的服务器进行同步?
没有这么先进吧

引用
请问MSSQL是否支持离线文件的发布和订阅?比如生成同步文件后再复制到要同步的服务器进行 ......

delphi如何获取mssql存储过程的返回值

存储过程是这么写的,
Declare @id int
    BEGIN TRANSACTION
 
      Insert into xxxxxTable(f1,f2)values(@a,@b)
      Select @id=@@identit ......

MSSQL中如何选择一行中最小的时间?

一张表,字段分为id,time1,time2,time3,time4,time5 
请问我应该如何选择ID为1的那条记录中time时间最小的值呢?
UP!

[code=SQL][/code]select min(t) from 
(select time1 as t from t1 where id ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号