sql for循环

declare @i int
 set @i = 1
while (@i < 5)
begin
   insert into table values(newid(),'','','')
   set @i = @i + 1
end

 

--------mysql的写法-----------

DROP PROCEDURE dowhile;
create PROCEDURE dowhile()
BEGIN
    DECLARE i int DEFAULT 0;
    START TRANSACTION;
          WHILE i<100 DO
                insert into table values(newid(),'','','') ;
        set i=i+1;
          END WHILE;
    COMMIT;
END
call dowhile();

你可能感兴趣的:(sql for循环)