SQL string manipulation [Get all text left of '(']
I think you've just put a wrong character
case when CHARINDEX('(', SourceOfBooking) > 0 then rtrim(left(SourceOfBooking, CHARINDEX('(', SourceOfBooking) - 1)) else SourceOfBookingend
You can;
LEFT(SourceOfBooking, CHARINDEX(' (', SourceOfBooking + ' (') - 1)
(Remove + ' ('
if needed; it allows for rows with no (
This will return the company name whether or not there is a bracket, and will also handle cases where there is no space before the bracket:
select case when CHARINDEX('(', SourceOfBooking) > 0 then RTRIM(LEFT(SourceOfBooking, CHARINDEX('(', SourceOfBooking) - 1)) else SourceOfBookingendfrom Table1