把你的SQL server 的 TIMEOUT调大一点!

解决方案 »

  1.   

    但是我現在不能去調sql server 隻能在程式裡解決。
      

  2.   

    1、
    sqlserver客户端-->开始菜单-->SQLserver-->客户端网络实用工具-->别名-->添加-->写入别名如"大力"-->"网络库"选tcp/ip-->服务器名称写入远程ip或实例名-->OK了2、换宽带
      

  3.   

    或用查询分析器登上后执行:SET LOCK_TIMEOUT 0
      

  4.   

    樓上的方法用了,不行。
    為什麼原來可以,現在就會出現這個問題!!!!
    急死人了,報表出不了!!!
    不管有沒有用,我還是把SQL語句貼上來吧!這麼長的語句我不知從那裡優化了!
    select distinct rtrim(a.cust_no) as cust_no, CASE WHEN c.cust_ename<>'' THEN c.cust_ename WHEN c.cust_name<>'' THEN c.cust_name ELSE '( 沒 有 記 錄 )' END AS cust_name, a.doc_no, a.txn_date, g.due_date, a.exch_rate, a.amount, b.cr_amt, d.db_amt, e.oc_amt, f.pay_amt as pay_amt from (( (ar a left outer join (select cust_no, inv_no, sum(cr_amt) as cr_amt from arcr where cr_no in (select doc_no from ar where txn_date < '2003/5/01' and R_P='R' and txn_type='C') group by inv_no, cust_no) as b on a.doc_no=b.inv_no) left outer join (select cust_no, inv_no, sum(db_amt) as db_amt from ardb where db_no in (select doc_no from ar where txn_date < '2003/5/01' and R_P='R' and txn_type='D') group by inv_no, cust_no) as d on a.doc_no=d.inv_no) left outer join (select cust_no, inv_no, sum(oc_amt) as oc_amt from aroc where ref_no in (select doc_no from ar where txn_date < '2003/5/01' and R_P='R' and txn_type='O') group by inv_no, cust_no) as e on a.doc_no=e.inv_no) left outer join (select cust_no, inv_no, sum(pay_amt) as pay_amt from arpay where chq_no in (select doc_no from ar where txn_date < '2003/5/01' and R_P='R' and txn_type='P') group by inv_no, cust_no) as f on a.doc_no=f.inv_no, customer c, arinv g where a.R_P='R' and (a.txn_type='I' or a.txn_type='A') and a.cust_no=c.cust_no and c.factoring=1 and c.cust_no between '80100' and 'TFPCL' and c.currency = 'HKD' and a.txn_date < '2003/5/01' and g.inv_no=a.doc_no order by a.cust_no, g.due_date, a.doc_no 
    補充一句,別的報表的SQL也很長,但是不會出現這個錯誤。
      

  5.   

    这种查询,简直是垃圾,这么多表相连,而且还用了n多的in
      

  6.   

    這是我的前任同事寫的,Table之間的關聯我也不清楚。(沒有任何的文件,實在很頭痛。)我現在隻想找出 a.amount, b.cr_amt, d.db_amt, e.oc_amt, f.pay_amt 這四個字段每個字段的加總值,sum(a.amount) as amount
    ...
    ...這樣執行起來會不會快一些?
    但是在group by 時總是出錯(group by cust_no),各位高手指點怎麼改寫?
    分不夠可再加!!!!!