Show in output rows retrieved/affect for each executed query

Hi, when running the following code:

 

UPDATE Game
SET Played = 1
WHERE Genre = 'FPS'

UPDATE Game
SET Played = 1
WHERE Title = 'Factorio'

Services/Output tab will return “667 rows affected”, where 667 is a sum of all affected rows. If I'd run SELECT for these conditions I'd only receive information that “1 row retrieved” (only the last UPDATE). Is it possible to change this behavior to show rows affected/retrieved for each individual statement (e.g. SQL Server Management Studio shows it this way, displaying separate messages for 666 and 1 row).

 

0

Hi, 

Am I correct that, in your case running, the two updates above resulted in a total count of affected rows of both tables written into the output? I tested a similar case and got two separate counts of affected rows when running an Update statement over two different tables
 

0

Hi, thanks for checking. This might be the thing w/ SQL Server only. By default the results will be as I've described above. However adding GO b/w the updates solves this issue:

Test> UPDATE test_table
     SET flag = 0
     WHERE name = 'false'
[2025-01-29 20:24:22] 1 row affected in 19 ms
Test> UPDATE test_table
     SET flag = 1
     WHERE name = 'true'
[2025-01-29 20:24:22] 2 rows affected in 11 ms

W/o GO:

Test> UPDATE test_table
      SET flag = 0
      WHERE name = 'false'
      
      --GO;
      
      UPDATE test_table
      SET flag = 1
      WHERE name = 'true'
[2025-01-29 20:27:27] 3 rows affected in 21 ms

Likewise SQLite does it by default:

main> UPDATE test_table
      SET flag = 0
      WHERE name = 'false'
[2025-01-29 20:23:21] 1 row affected in 1 ms
main> UPDATE test_table
      SET flag = 1
      WHERE name = 'true'
[2025-01-29 20:23:21] 2 rows affected in 1 ms

So far I don't see any option to change that behavior in SQLServer, so maybe that's just how it is currently.

0
It seems to have the same effect when running from the CLI and how it returns the resultset by the database engine
0

请先登录再写评论。