Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

SQL - Rows Affected Without Running Query

Posted on 2008-10-03
3
465 Views
Last Modified: 2012-05-05
When I write a query on a table in SQL Management Studio, I can verify it then run it, then it tells me the number of rows affected.  Is there any way I can write the query, verify it, find out how many rows would be affected, then execute it?  I suppose this goes for any query really!  I just want to know what will be affected before executing the query.
0
Comment
Question by:redmission
3 Comments
 
LVL 60

Expert Comment

by:chapmandew
ID: 22634835
Nope, you have to run the query to know how many rows will be affected.
0
 
LVL 11

Accepted Solution

by:
indianguru2 earned 250 total points
ID: 22634951
Add
Begin Transaction -- At the start of the Query

Rollback transaction -- At the end of the Query

Run the Query to get the results or the rows affected. When satisfied, remove it and run again.,
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22634990
I assume this is an update statement?  If it's a select, and you just want an easy way to get a rowcount first.

select count(*) from (YOURQUERY) a

then execute YOURQUERY.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question