I need to test for a condition within a string. I'm using a simple condition below just to make the example easy to work with. But even this simple example doesn't work once the condition is added. What am I doing wrong?
SELECT '<p><input type="checkbox" name_' + CAST(mt.personid AS VARCHAR) + CASE WHEN 1=1 THEN 'checked' + END '></p>' AS MyContent from mytable mt
Incorrect syntax near the keyword 'END'
If I remove the plus after 'checked', I get:
Incorrect syntax near the keyword 'AS'