September 28, 2015 at 3:26 pm
Would this update statement work? both the SET & WHERE have the same columns:
Update Table S_Offce
SET rep_name = 'Larry'
WHERE rep_name = 'Berry'
I have no other column that could uniquely identify Berry.
thank you
September 28, 2015 at 3:46 pm
It should. It will update every record that would be selected by the filter, though. So you may update more records than you intended to.
September 28, 2015 at 3:48 pm
Yes there are approx. 200 records where Berry needs to be replaced with Larry.
September 28, 2015 at 3:58 pm
execute a select statement with the same filter to make sure you don't get any false positives, and when you've fixed that part, use the filter/where clause in your update statement.
see if this returns any values you don't want...
SELECT *
FROM S_Office
WHERE rep_name = 'Berry';
Then if it's okay
UPDATE S_Office
SET rep_name = 'Larry'
WHERE rep_name = 'Berry';
September 29, 2015 at 4:41 am
Just in case of interest I write UPDATEs with an Alias so that we can test them with minimal code changes
UPDATE U
-- [highlight="#ffff11"]SELECT *
-- SELECT COUNT(*)
FROM S_Office AS U
WHERE rep_name = 'Berry';[/highlight]
I highlight from one of the SELECT debug statements to the end and EXECUTE that to check, and it is it is OK then I run the UPDATE.
Also possible to toggle the "--" comment on this (if it is buried in a procedure) to get an output rather than an update
[highlight="#ffff11"]-- UPDATE U
SELECT *[/highlight]
-- SELECT COUNT(*)
FROM S_Office AS U
WHERE rep_name = 'Berry';
My personal preference is to try to write this in a way that has minimal code change between the test and runtime options so there is less chance of my wrecking something when I toggle it ove 😉
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply