存储过程中代码的优化问题?
以下内容是存储过程中的一段,由于数据量较多,后面的UPDATE语句执行很慢,请大家帮忙看看如何优化
SELECT orgnid,
orgnno,
orgnname
INTO #a001orgn
FROM a001orgn
WHERE a001orgn.orgnno LIKE @OrgnNO + '% '
SELECT accgyearid,
acctid,
pacctid,
acctno,
acctname,
nolevel,
islowestlevel,
balancedirection
INTO #a111acctitle
FROM a111acctitle
WHERE acctno LIKE @AcctNo + '% '
ORDER BY acctno
SELECT #a001orgn.orgnno,
#a001orgn.orgnname,
#a111acctitle.acctno,
#a111acctitle.acctname,
Cast(0 AS money) AS ncye,
Cast(0 AS money) AS qcye,
Cast(0 AS money) AS qmye,
Cast(0 AS money) AS bqjf,
Cast(0 AS money) AS bqdf,
Cast(0 AS money) AS bnlj,
Cast(0 AS money) AS bnld,
Cast(0 AS money) AS qmjf,
Cast(0 AS money) AS qmdf,
Cast(0 AS money) AS xjjf,
Cast(0 AS money) AS xjdf,
#a111acctitle.nolevel,
#a111acctitle.islowestlevel
INTO #orgnacct
FROM #a001orgn,
a110accg,
a111accgyear,
#a111acctitle
WHERE #a001orgn.orgnid = a110accg.orgnid
&