日期:2014-05-18  浏览次数:20637 次

SQL语句执行顺序,中级.
if(@AllSame=1)
        select   *   from   test_sms   where   flag=1   and   id   in(select   smsid   from   dbo.sms_status   where   TotalCom=@Total   and   ComId=@Id   )   order   by   id   asc     delay   waitfor   '00:00:05 '
else
        select     *   from   test_sms   where   flag=1   and   id   in(select   smsid   from   dbo.sms_status   where   TotalCom=@Total   and   ComId=@Id   and   CardType=@CardType)   order   by   id   asc

update   sms_relation   set   flag=0
update   test_sms   set   flag=3   where   flag=1   and   id   in(select   smsid   from   dbo.sms_status)
delete   from   sms_status
------------------------

执行顺序不能变。在执行SELECT后,后面的语句马上跟着一起执行。
现在是在执行SELECT   后,等到Select   操作完再能执行下面

------解决方案--------------------
去掉delay waitfor '00:00:05 ',这个语句的意思时延时5秒.