SQL code to remove contact point purposes from inactive addresses

Hello,

I'm trying to use SQL to remove contact point purposes from addresses that are marked inactive. I've come up with a query that pulls these addresses, but I am having trouble figure out the DELETE command. Any ideas?

Here's my code so far:
SELECT * FROM [impresario].[dbo].[VS_ADDRESS] as a
JOIN [impresario].[dbo].[TX_CONTACT_POINT_PURPOSE] as c
ON a.address_no = c.contact_point_id
WHERE inactive = 'Y'

Thanks!
Anne

Parents
  • First: Always do this in Test first!  Then, something like this:

    select * from TX_CONTACT_POINT_PURPOSE

    begin transaction

    delete cpp

    from TX_CONTACT_POINT_PURPOSE as cpp

    inner join T_ADDRESS as a on a.address_no = c.contact_point_id

    and a.inactive =  'Y'

    select * from TX_CONTACT_POINT_PURPOSE

    --commit transaction

    rollback transaction

Reply
  • First: Always do this in Test first!  Then, something like this:

    select * from TX_CONTACT_POINT_PURPOSE

    begin transaction

    delete cpp

    from TX_CONTACT_POINT_PURPOSE as cpp

    inner join T_ADDRESS as a on a.address_no = c.contact_point_id

    and a.inactive =  'Y'

    select * from TX_CONTACT_POINT_PURPOSE

    --commit transaction

    rollback transaction

Children