Adel
Adel

Reputation: 17

how to find Second char from a special char in sql

i have this= 'student 1-99-98 - 281 - 1567519464' an this length is dynamic i want Phrase of after last '-' i want to extract this='1567519464' please help me in Microsoft SQL query

Upvotes: -1

Views: 93

Answers (1)

Praful Bangal
Praful Bangal

Reputation: 59

SELECT Ltrim(rtrim(RIGHT('student 1-99-98 - 281 - 1567519464', (CHARINDEX('-',REVERSE('student 1-99-98 - 281 - 1567519464'),0)-1))))

Upvotes: 0

Related Questions