I have the following ID in my database:
Declare @YourTable Table ([SomeCol] varchar(50))
Insert Into @YourTable Values 
('1111-DXA-'),
('111-BCN-C1'),
('111-DEL-C1'),
('111JK1004JK1-000000/002'),
('11111-GOT-17C5'),
('11111-JHB-0' );
SELECT RTRIM(LTRIM(REVERSE( 
            SUBSTRING(
                    SUBSTRING(REVERSE([SomeCol]) , CHARINDEX('-', REVERSE([SomeCol]))  +1 , LEN([SomeCol]) )
                     , 1 , CHARINDEX('-', SUBSTRING(REVERSE([SomeCol]) , CHARINDEX('-', REVERSE([SomeCol]))  +1 , LEN([SomeCol]) ) ) -1
                    )
                )))
FROM @YourTable
Exception :Invalid length parameter passed to the LEFT or SUBSTRING function.
Can you pls suggest me on this.
