[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQL - Rows Affected Without Running Query

Posted on 2008-10-03
3
Medium Priority
?
474 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 1000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
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…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

834 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