Hi,
I have some records and I need to take the character before '-'. for example
J055-0002.0K-00 (1000) the result will be J055
or
J055A-0002.0K-00 (1000) the result will be JO55A
what syntax should I put?
thx,
Joe
Hi,
I have some records and I need to take the character before '-'. for example
J055-0002.0K-00 (1000) the result will be J055
or
J055A-0002.0K-00 (1000) the result will be JO55A
what syntax should I put?
thx,
Joe
create table dbo.shimsham(boozbaz nvarchar(150));
insert into dbo.shimsham
select 'J055-0002.0K-00 (1000)' union
select 'J055A-0002.0K-00 (1000)'
select substring(boozbaz, 0, charindex('-',boozbaz))
from dbo.shimsham
SELECT LEFT(column_name, CHARINDEX('-', column_name + '-') - 1), ...
FROM ...