1

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

2
  • Is the image tag the only thing in the field, or is it jus a part of a larger html "blob"? Commented Oct 6, 2012 at 11:39
  • Then I'm sorry to say that you can probably create a horrible horrible hack that solves your problem, but it's definitely not a problem SQL is made for :-/ Commented Oct 6, 2012 at 11:42

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

well it is giving me error "Invalid length parameter passed to the LEFT or SUBSTRING function."
@rahul that is strange, it is working on the SQL Fiddle. Can you create a SQL Fiddle with some additional data and post the link here?
problem is that my html is not in fix format as i have mentioned on top it is just a part of random html.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.