Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Verify Results before Executing

Author  Topic 

hissein
Starting Member

5 Posts

Posted - 2012-08-07 : 23:23:27
Hi guys,

Is there a way i can veryfiy the number of affected raws by a query (update or Delete) before executing?

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2012-08-08 : 01:52:01
You can do this by running a SELECT statement over the exepected recordset.
So, you could execute a SELECT , run some rules over the recordset - and then DELETE | UPDATE once confirmed

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-08-08 : 03:02:08
You can use the Estimated Execution Plan to get a rough estimate.


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2012-08-08 : 16:42:01
Or u can do

BEGIN TRANSACTION;
GO
-- ur query
GO

-- Then select either of the following
COMMIT TRANSACTION;
GO

rollback TRANSACTION;

Srinika
Go to Top of Page
   

- Advertisement -