Skip to content
Advertisement

How to separate values using Sub string for sql Eg-Data 42ND-1000 W61ST-1000 TIFF-1000 THIR-1000 and i want data before – eg-42ND

I am getting the following data:

42ND-1000 
W61ST-1000 
TIFF-1000 
THIR-1000 

and I want to get the data before the -.

For 42ND-1000 I want 42ND only.

Advertisement

Answer

This is basic string manipulation. In SQL Server, you would do:

select left(col, charindex('-', col + '-')- 1)
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement