MYsql如何像SqlServer一样在查询分析器中执行多行语句
use pubsdeclare @fid int declare @milestone intdeclare @count intdeclare @val intset @fid = 1set @milestone = 1truncate table milestone--得到总的milestone数select @count = count(1) / 10000from threadwhere fid = @fid--第一个milestoneselect top 1 @val = lastpostfrom thread with ( nolock )where fid = @fid and lastpost not in ( select top 10000 lastpost from thread with ( nolock ) where fid = @fid order by lastpost desc )order by lastpost descinsert into milestone ( fid, milestone, lastpostdesc )values ( @fid, @milestone, @val )set @milestone = @milestone + 1while ( @milestone <= @count ) begin select top 1 @val = lastpost from thread with ( nolock ) where fid = @fid and lastpost < @val and lastpost not in ( select top 10000 lastpost from thread with ( nolock ) where fid = @fid and lastpost < @val order by lastpost desc ) order by lastpost desc insert into milestone ( fid, milestone, lastpostdesc ) values ( @fid, @milestone, @val ) set @milestone = @milestone + 1 end