SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Verify Results before Executing
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

hissein
Starting Member

Malaysia
5 Posts

Posted - 08/07/2012 :  23:23:27  Show Profile  Reply with Quote
Hi guys,

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

jackv
Flowing Fount of Yak Knowledge

United Kingdom
1770 Posts

Posted - 08/08/2012 :  01:52:01  Show Profile  Visit jackv's Homepage  Reply with Quote
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

Sweden
29138 Posts

Posted - 08/08/2012 :  03:02:08  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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
Flowing Fount of Yak Knowledge

Sri Lanka
1378 Posts

Posted - 08/08/2012 :  16:42:01  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000