I have a table with 4 columns: Science, Math, English, and Classes. Science, Math, and English are booleans, and Classes is nvarchar.
If Science is 1, then Classes should get appended with a semicolon and the string 001. If Math is 1, then Classes should get appended with a semicolon and the string 002. If English is 1, then Classes should get appended with a semicolon and the string 003.
So if Science was 1, Math was 0, and English was one, then Classes would have 001;003. Or if Science was 0, Math was 1, and English was zero, then Classes would have 003.
I initially tried:
Update Table
SET Classes = CASE
WHEN Science = 1 THEN concat(Classes, ';001')
WHEN Math = 1 THEN concat(Classes, ';002')
WHEN English = 1 THEN concat(Classes, ';003')
END
But this won't work because as soon as the CASE finds a true statement, it updates that and won't check the other conditions. Can anyone help with figuring out how to do this kind of concatenation? Thanks!