潜心研究和实践.NET/数据库相关技术的应用;

关注NBA,酷爱乡村音乐。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

不知哪位碰到这样的问题,请知道的朋友指数,谢谢!

我的数据库用的是sql server 2000,升级之前一切正常,但升级到2005后,一个存在过程在被调用运行的过程中出现了问题,而且是隔几天又没事,隔几天又出现问题,反反复复,真的奇怪。不行的时候提示的信息如下(在.net 2003和2008中都如此) 

“超时时间已到。在操作完成之前超时时间已过或服务器未响应。”

但把该存储过程的代码弄在查询窗口中运行又不会出现问题,真的是百思不得其解。

不知道是否.net代码在调用sql server 2005存储过程是不时要进行其它的处理,请知道的朋友指教,谢谢。存储过程的代码如下:

ALTER PROCEDURE dbo.JIT_Sha_Dairy_RptTemp_UseInRpt03_1

@dt1 as datetime,
@dt2 as datetime,
@CCode char(4)--,

AS

declare @weight_浅色 decimal(12,2)
declare @weight_中色 decimal(12,2)
declare @weight_深色 decimal(12,2)
declare @weight_漂白白色 decimal(12,2)

set @weight_浅色 = 0
set @weight_中色 = 0
set @weight_深色 = 0
set @weight_漂白白色 = 0

declare @WeightTable table
(
 weight_浅色 decimal(17,4),
 weight_中色 decimal(17,4),
 weight_深色 decimal(17,4),
 weight_漂白白色 decimal(17,4)
)

declare @dairyTable table
(
 客户编号 char(4),
 缸号 char(18),
 百分比总和 decimal(12,4),
 产量 decimal(12,2)
)

--以下统计染色
insert into @dairyTable
select
 d.CCode as 客户编号,
 b.Job_No as 缸号,
 sum(a.Baifenbi) as 百分比总和,
 avg(c.Weight_Dairy) as 产量
from Sha_Piaorandan1 a left outer join Sha_Piaorandan b
 on a.Piaoran_No = b.Piaoran_No
left outer join Sha_Paigang c on b.Job_No = c.Job_No
left outer join Contract_Total d on c.Cont_No = d.Cont_No
where
 c.Finish = 'Y'
 and c.Prod_Date between @dt1 and @dt2
 and a.RCode not like 'C%'
 and a.RCode <> ''
 and b.Piaoran_Type not in ('YBC','YBS') --漂白/YBC,半漂/YBS不参加进去,假设该单不领染料
group by d.CCode,b.Job_No

if @CCode <> ''
 delete @dairyTable where 客户编号 <> @CCode
 
select @weight_浅色 = sum(产量) * 0.9 from @dairyTable where 百分比总和 <= 1.5

select @weight_中色 = sum(产量) * 1 from @dairyTable where 百分比总和 > 1.5 and 百分比总和 <= 3.5

select @weight_深色 = sum(产量) * 1.35 from @dairyTable where 百分比总和 > 3.5

--以下统计漂白/YBC,半漂YBS
--先把之前的资料删除
delete @dairyTable

insert into @dairyTable
select
 d.CCode as 客户编号,
 b.Job_No as 缸号,
 sum(a.Baifenbi) as 百分比总和,
 avg(c.Weight_Dairy) as 产量
from Sha_Piaorandan1 a left outer join Sha_Piaorandan b
 on a.Piaoran_No = b.Piaoran_No
left outer join Sha_Paigang c on b.Job_No = c.Job_No
left outer join Contract_Total d on c.Cont_No = d.Cont_No
where
 c.Finish = 'Y'
 and c.Prod_Date between @dt1 and @dt2
 and b.Piaoran_Type in ('YBC','YBS') --漂白/YBC,半漂/YBS
group by d.CCode,b.Job_No

if @CCode <> ''
 delete @dairyTable where 客户编号 <> @CCode
 
select @weight_漂白白色 = sum(产量) * 0.6 from @dairyTable

insert into @WeightTable values(@weight_浅色, @weight_中色 , @weight_深色, @weight_漂白白色)

select * from @WeightTable


 

posted on 2008-12-02 13:58  黄永泰  阅读(731)  评论(3编辑  收藏  举报