简体   繁体   中英

multi-Insert using sqlsrv_query

the code below is designed to insert n rows into a table. However, for all n >=108, it manages to insert only 108 rows. Works fine for n<108. I run the query on database and it works as expected. Has any of you guys had a similar issue?. Any help would be appreciated.

    $data = "a1='1', a2='2', a3='3', a4='4', a5='5', a6='6'";
    $queryInsert = 
    "   SELECT $data INTO [$tableName]
        DECLARE @i int
        SET @i=1
        WHILE (@i < $n)
        BEGIN
            INSERT [$tableName]
            SELECT $data
            SET @i = @i + 1
        END
    ";
    $stmt1 = sqlsrv_query($conn1, $queryInsert);

EDIT: PHP7, Driver version: 4

Apparently this works now. No idea why.

$data = "a1='1', a2='2', a3='3', a4='4', a5='5', a6='6'";
    $queryInsert = 
    "   SELECT $data INTO [$tableName]
        DECLARE @i int
        SET @i=1
        WHILE (@i < $n)
        BEGIN
            INSERT [$tableName]
            SELECT $data
            SET @i = @i + 1
        END
    ";
    $stmt1 = sqlsrv_query($conn1, $queryInsert);
    sleep ( 1 );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM