Skip to content

The intermediate totals rely on "row(s) affected" or other line separation between queries #42

@RichardBrookfield

Description

@RichardBrookfield

I spotted this problem on a much more complicated piece of SQL where the same table was used in two consecutive queries. It reacts in the same way in simple cases too, e.g. SQL like this on AdventureWorks:

set statistics io on
set nocount on
select top 100 * from Person.Address
set nocount off
select top 100 * from Person.Address

will work correctly. However, if the count is completely turned off, e.g.:

set statistics io on
set nocount on
select top 100 * from Person.Address
select top 100 * from Person.Address

then it will not.

Let's assume this generates 4 Logical Reads on Address for each execution.

  1. Without "rows affected", it reports subtotals of 8+4=12 (wrong), but total 8 (correct)
  2. With "rows affected", it correctly reports two queries of 4 each and then a correct total of 8

Even just a newline in the output (between the two queries) is enough to correct the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions