Reputation: 317
Typically, I test an update by running a query using the where statement and then after verifying that it does what I think I want it to copying the where clause to the update statement and executing it. But is there any way of getting the statement to return what the update did besides the '4 rows updated'
Upvotes: 2
Views: 118
Reputation: 5695
That depend in the server, library that you use, in php, pdo exec return number of row effected by delete or update cluase
Upvotes: 0
Reputation: 100577
You could load your records into a temp table/variable in SQL Server:
DECLARE @Temp TABLE(ID INT)
INSERT INTO @Temp (ID)
SELECT ID
FROM Customer
WHERE AcctBalance > 5000
--inspect as needed
UPDATE Customer
SET AcctBalance = 0
WHERE ID IN (SELECT ID FROM @Temp)
Upvotes: 0
Reputation: 12102
Sure, take a look at the output clause of T-SQL http://msdn.microsoft.com/en-us/library/ms177564.aspx
Upvotes: 1