Solved

SQL - Rows Affected Without Running Query

Posted on 2008-10-03
3
467 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
[X]
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
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

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…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
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…

739 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