Skip to content
Advertisement

Invalid syntax error near ‘<' when using case when variable, works fine without variable

I am trying to resolve this SQL issue where my code throws an error

Invalid syntax error near ‘<‘

when I use the variable @totalprice. Without using the variable, the CASE works and the query executes correctly but I want it as a variable

Thanks

Advertisement

Answer

If you want to assign the result of the CASE expression to your variable – use this code:

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