Posted by: tahir
SQL Help - 07/06/2021 16:50
In T-SQL how do I trim all characters after a character? I have a mixed bag of Style references to process, all different lengths, some with a 5 character suffix after '.', some with 4 character suffix after '.' and others with no suffix at all. So if my raw data was:
FJ210001.D023
FJ210002.D023S
LJA002
I'd like the results to be shown as:
FJ210001
FJ210002
LJA002
Any help appreciated
Posted by: andy
Re: SQL Help - 07/06/2021 18:05
Posted by: tahir
Re: SQL Help - 08/06/2021 11:06
Thanks, I'd never even heard of the function. Took me a while to figure out why I was getting "Invalid length parameter passed to the LEFT or SUBSTRING function" but all sorted now.
Posted by: andy
Re: SQL Help - 08/06/2021 11:59
I've not done any T-SQL in many years, so that was all thanks to Google and StackOverflow
Posted by: tahir
Re: SQL Help - 08/06/2021 12:55
I was searching for SUBSTRING and TRIM, so I guess wouldn't have found those
Posted by: andy
Re: SQL Help - 08/06/2021 14:05
I think I searched for "transact sql regex" and found CHARINDEX instead.
Posted by: tahir
Re: SQL Help - 09/06/2021 11:48
Yeah, did think regex would help, just wasn't sure how it would work with sql.