0

i am newbie in sql server, my requirement is i want to get the image path from the database field, but stuck what could be the query can anyone out there help me with this.

this is my format

<div align=center><imge src=/portals/0/logo.gif width=279 height=86 /></div>

i need /portals/0/logo.gif from the above html, using t-sql

Abbas
  • 4,948
  • 31
  • 95
  • 161
  • You have a bunch of useless text (
    ) stored in your database, or you have an actual database table containing file names somewhere and you need help getting those file names into your HTML? Or do you not have a database at all, and you want to parse some HTML which is what it looks like you're saying.
    – Kevin Stricker Oct 11 '11 at 16:36
  • NO, i have a field which contains, this bunch of text, and i want to get the file path from this. – Abbas Oct 11 '11 at 16:40
  • 3
    This is not a job for SQL - it's a job for whichever language you are querying the database with. E.g. [How to parse an HTML with PHP/ASP.NET?](http://stackoverflow.com/q/2146619) – Pekka Oct 11 '11 at 16:43
  • Why is the data stored in the database like that? – jcolebrand Oct 11 '11 at 16:55

1 Answers1

1

You would want your database table to look something more like this to avoid the problem of parsing the filename out of that HTML in the first place. You can always reconstruct the if you have all the varying data stored separately in the database.

CREATE TABLE images (
    id int IDENTITY,
    path nvarchar(255),
    width int,
    height int
)

If you have some existing data you just want to extract file names from, I would recommend using a tool other than an RDBMS.

Kevin Stricker
  • 17,178
  • 5
  • 45
  • 71