find out how many records a query would return without executing it

  • Dear Experts,

    It may be a silly question, please pardon me as I am a novice DBA, Is there a way to find out how many records a query would return without actually executing it? At first I thought this is possible via the 'display estimated execution plan' however I can't seem to get my head around the cost figures being displayed.

    We use SQL Server 2008 standard

    Thanks

    Raj

  • No.

    The estimated execution plan can give you the estimated number of rows, but that could be exactly correct, slightly wrong or several miles out depending on a large number of factors

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Like Gail says, the only way to know exactly what a query will return is to run it. Even if the statistics were accurate 30 seconds ago, they may no longer be accurate because a row got inserted.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply