当前位置: 代码迷 >> Sql Server >> SQL语句执行顺序,中级.该如何处理
  详细解决方案

SQL语句执行顺序,中级.该如何处理

热度:77   发布时间:2016-04-27 16:18:18.0
SQL语句执行顺序,中级.
if(@AllSame=1)
        select   *   from   test_sms   where   flag=1   and   id   in(select   smsid   from   dbo.sms_status   where   [email protected]   and   [email protected]   )   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   [email protected]   and   [email protected]   and   [email protected])   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秒.
  相关解决方案