Solved

SQL - Rows Affected Without Running Query

Posted on 2008-10-03
3
461 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
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 …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now