首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

SQL效率有关问题

2012-03-26 
SQL效率问题SQL codeDeclare @CurrentID int, @JobCode char(10),@Date char(10),@Time char(4)BEGIN TRYS

SQL效率问题

SQL code
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会很慢 请问有什么办法能增加效率

[解决办法]
SQL code
update a  SET Time1=b.[Time] from Atd_DayResult a,Atd_DataReceive bwhere a.JobCode =b.JobCode and a.[Date]=b.[Date] 

热点排行
Bad Request.