rahul
rahul

Reputation: 7663

Extract string from another string in sql server 2008

i have a table in which i save form html which include image also like this

<img src="../UploadedFiles/2143_logo.png" >
<img src="../UploadedFiles/2343_New_logo.jpeg" >
<img src="../UploadedFiles/2786_old_logo.bmp" >

i want to extract image name for each record like this

2143_logo.png

2343_New_logo.jpeg

2786_old_logo.bmp

i don't know how to get it done please help me out

thanks in advance

Upvotes: 1

Views: 425

Answers (1)

Taryn
Taryn

Reputation: 247860

This is a very ugly way to do this:

select 
  replace(replace(reverse(left(reverse(yourColumn), charindex('/', reverse(yourColumn)) -1)), '>', ''), '"', '')
from yourtable

See SQL Fiddle with Demo

Upvotes: 1

Related Questions