Using SQL to inactivate workers: what am I doing wrong?

Hi all! I am trying to do a cleanup of all of our workers by making around ~175 of them inactive, and as a beginner SQL user I'd appreciate the community's review/advice on my code.

Here is what I'm trying to update on these constituent records:

And I have a static list of all of the workers that need to be made inactive (list # 133113).

So the SQL script I came up with is as follows:

Use impresario
select *
from T_LIST_CONTENTS a
left outer join TX_CUST_WORKER_TYPE b
on a.customer_no=b.worker_customer_no
where a.list_no='133113'
and b.inactive = 'n'

--below is a separate part of the code to run.
begin transaction
update TX_CUST_WORKER_TYPE
set inactive = 'y'
where worker_customer_no in
(select b.worker_customer_no from T_LIST_CONTENTS a
left outer join TX_CUST_WORKER_TYPE b on a.customer_no=b.worker_customer_no
where a.list_no='133113')
commit

I tried this in Test, but I must have done something wrong; afterwards, opening any of the affected accounts would cause Test to crash. (I did a Prod to Test copy last night, so Test is now working properly again).

Many thanks in advance for any tips or advice!

Liz 

Parents Reply Children