I am using SSMS 2008 and am looking for a way to replace records according to the following logic. I want everything listed from one column that occurs before the question mark. Example current column data:
SUICIDAL? If yes, please describe
HOMICIDAL? If yes, please describe the following
PSYCHOTIC BEHAVIOR? If yes, please describe. If no then?
...
I want this to instead read:
SUICIDAL?
HOMICIDAL?
PSYCHOTIC BEHAVIOR?
...
Note that it should only include everything before the FIRST question mark, so in the third record it should only return “PSYCHOTIC BEHAVIOR” and not everything ending in “then”.
How do I code this? I tried the following expression in TSQL but this didn’t work:
replace('?%',[test_details].[test_setup_details_caption],'?')
TRY: