Solved

SQL - Rows Affected Without Running Query

Posted on 2008-10-03
3
464 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

821 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