数据库从Sql server 2000升级到2005后,遇到一点问题。

作者升级数据库从SQL Server 2000到2005后,遇到存储过程在.NET环境中调用时偶尔出现超时的问题。该问题表现不稳定,且直接执行存储过程代码正常。

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

我的数据库用的是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


 

转载于:https://www.cnblogs.com/OldYongs/archive/2008/12/02/1345755.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值