CREATE PROCEDURE it_it121 asupdate project_send set al_send_time=it_198.info_data_uptime from it_198 where it_198=send_time=convert(char(5),getdate(),8) and project_send.tocode=it_198.tocodego
update project_send set al_send_time=a.info_data_uptime from from it_198 a where project_send.tocode=a.tocode and a.send_time=convert(char(5),getdate(),8) --这样不就行了么,为什么要有游标呢
多写了个=号:CREATE PROCEDURE it_it121 asupdate project_send set al_send_time=it_198.info_data_uptime from it_198 where it_198.send_time=convert(char(5),getdate(),8) and project_send.tocode=it_198.tocodego
我也是新手,在学习中,是另一个人做, 原本是一个作业30分钟运行一次这个存储过程,把视图it_198中符合条件的结果送到web_send,再把project_send 表的al_send_time字段update为某值,现在是project_send 记录一多现在仅仅24000条,作业时间就超过30分钟 。 现把它改成大力和小黑的方法后用了8-10分钟。 如下: CREATE PROCEDURE it_it121 as declare @now_time varchar(5) set @now_time=convert(char(5),getdate(),8) print @now_time insert into web_send (phone,msgcontent,tocode) select mobile_id,msg_cont,tocode from it_198 where send_time=@now_timeupdate project_send set al_send_time=it_198.info_data_uptime from it_198 where it_198.send_time=@now_time and project_send.tocode=it_198.tocode GO还有更快的方法?
asupdate project_send set al_send_time=it_198.info_data_uptime from it_198 where it_198=send_time=convert(char(5),getdate(),8) and project_send.tocode=it_198.tocodego
set al_send_time=a.info_data_uptime
from from it_198 a
where project_send.tocode=a.tocode and a.send_time=convert(char(5),getdate(),8) --这样不就行了么,为什么要有游标呢
asupdate project_send set al_send_time=it_198.info_data_uptime from it_198 where it_198.send_time=convert(char(5),getdate(),8) and project_send.tocode=it_198.tocodego
原本是一个作业30分钟运行一次这个存储过程,把视图it_198中符合条件的结果送到web_send,再把project_send 表的al_send_time字段update为某值,现在是project_send
记录一多现在仅仅24000条,作业时间就超过30分钟 。
现把它改成大力和小黑的方法后用了8-10分钟。
如下:
CREATE PROCEDURE it_it121 as
declare @now_time varchar(5)
set @now_time=convert(char(5),getdate(),8)
print @now_time
insert into web_send (phone,msgcontent,tocode) select mobile_id,msg_cont,tocode from it_198 where send_time=@now_timeupdate project_send set al_send_time=it_198.info_data_uptime from it_198 where it_198.send_time=@now_time and
project_send.tocode=it_198.tocode
GO还有更快的方法?