Declare @CurrentID int, @JobCode char(10),@Date char(10),@Time char(4)
BEGIN TRY
SET @CurrentID = 1;
Select @JobCode = JobCode,@Date = [Date],@Time = [Time]
from Atd_DataReceive
where DataReceiveId = @CurrentID;
WHILE (@@ROWCOUNT >= 1)
BEGIN
UPDATE Atd_DayResult
SET Time1 = @Time
WHERE JobCode = @JobCode AND AtdDate = @Date
SET @CurrentID = @CurrentID + 1;
SELECT @JobCode = JobCode,@Date = [Date],@Time = [Time]
from Atd_DataReceive
WHERE DataReceiveId = @CurrentID;
END
COMMIT TRANSACTION
END TRY
如上代码,当Atd_DataReceive 和Atd_DayResult的数据很多时 这段SQL会很慢 请问有什么办法能增加效率
BEGIN TRY
SET @CurrentID = 1;
Select @JobCode = JobCode,@Date = [Date],@Time = [Time]
from Atd_DataReceive
where DataReceiveId = @CurrentID;
WHILE (@@ROWCOUNT >= 1)
BEGIN
UPDATE Atd_DayResult
SET Time1 = @Time
WHERE JobCode = @JobCode AND AtdDate = @Date
SET @CurrentID = @CurrentID + 1;
SELECT @JobCode = JobCode,@Date = [Date],@Time = [Time]
from Atd_DataReceive
WHERE DataReceiveId = @CurrentID;
END
COMMIT TRANSACTION
END TRY
如上代码,当Atd_DataReceive 和Atd_DayResult的数据很多时 这段SQL会很慢 请问有什么办法能增加效率
where a.JobCode =b.JobCode and a.[Date]=b.[Date]
这样写不就可以吗
from Atd_DataReceive
where DataReceiveId = @CurrentID;