Skip to content
Advertisement

value in column between commas delimited

I have data in the table where all values in the column between double commas

example: ‘EGHU3158543’

when inquiry the data I need to delete the first comma and last comma, I used the following code :

SELECT  ['EQ_NBR']   
FROM [OldExpress].[dbo].[SERVICE_EVENTS]
WHERE Substring(['EQ_NBR'], 1, LEN(['EQ_NBR']) - 1) = 'EGHU3158543'

it gives me error as result : Invalid length parameter passed to the LEFT or SUBSTRING function.

Advertisement

Answer

it solve now by using the following code :

SELECT

EQ_NBR, LEFT (RIGHT (EQ_NBR, len (EQ_NBR)-1),len(EQ_NBR)-2)as RemovalOfFiratAndLastCharacter

FROM [OldExpress].[dbo].[EQUIPMENT_USES]

where EQ_NBR like ””+’EGHU3158543’+””

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement