Skip to content
Advertisement

SET .. WHERE .. within batch throwing an error in SSMS v18.4

I am revisiting MS SQL after a few years, so apologies for a basic question!

I am performing some address data cleansing, to expand abbreviations like DR into ‘DRIVE’ RD into ‘ROAD’ etc to help with identifying duplicate addresses.

I am exploring ways to optimise my query by taking my existing block of 10 sequential SET .. WHERE .. statements into a batch or some other method, as I am working on approximately 500k records.

When I converted my block of existing SET .. WHERE .. statements into a simple batch, this is throwing an “incorrect syntax near the keyword where” error. Does anyone have any ideas or suggestions to resolve this? Here is what the code looks like (with a cut down list of SET .. WHERE .. statements):

Many thanks in advance for your help.

Advertisement

Answer

That’s not the correct syntax for the SET clause of an UPDATE statement. You’re looking for CASE.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement