I want to loop CustomerType column in CustomerDetails table. then use the condition where CustomerType = 'CorporateCustomer' to update IsCorporateCustomer column to 1 and else update others to 0
This is what I did but It only executes the first statement and added 1 to all the IsCorporateCustomer column.
How can I fix this? Thanks
IF EXISTS (SELECT * FROM CustomerDetails WHERE CustomerType = 'CorporateCustomer')
BEGIN
UPDATE CustomerDetails set IsCorporateCustomer = 1;
END
ELSE
BEGIN
UPDATE CustomerDetails set IsCorporateCustomer=0;
END