Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > ORDER BY should ignore HTML tags while sorting
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 23rd April 06:04
denzilpereira
External User
 
Posts: 1
Default ORDER BY should ignore HTML tags while sorting



Hi...

I need to sort (ORDER BY) the data in a table alphabetically. Now it
may so happen that the data could contain HTML tags embedded and the
special first char "<" of the HTML opening tag is used for the ORDER
BY clause and hence in the following sample of data I have, I always
have <B>Tiger</B> as the first row.

I need to escape just the HTML tags (<B> in this case and also double
quotes) for my ORDER BY... What's the best way to achieve this...

Original Table data
Data in Column1 - Dog
Data in Column2 - <B>Tiger</B>
Data in Column3 - Zebra

After doing a ORDER BY
<B>Tiger</B> --I need this to be the 2nd row ... i.e. ignore <B> for
the sort
Dog
Zebra

Any pointers/ suggestions will be appreciated.
Thanks for your time.

Cheerz...
Denzil
  Reply With Quote


  sponsored links


2 23rd April 06:04
john bell
External User
 
Posts: 1
Default ORDER BY should ignore HTML tags while sorting



Hi

You may get away with something like:

SELECT Col
FROM MyTable
ORDER BY RIGHT(Col, LEN(Col)-PATINDEX('%>%',Col))

or maybe extensive use of the replace function. Another solution would be to
hold a clean version of the data.


John
  Reply With Quote
3 23rd April 06:04
denzilpereira
External User
 
Posts: 1
Default ORDER BY should ignore HTML tags while sorting


Dear John...

Thanks a lot for ur help... Got another nice way of doing it... Thanks to u...

I tried the same using the following (REPLACE)...

<snip>
when (@TempStr = '<B>')
then replace (ltrim(rtrim(MyCol)), @TempStr, '')
<snip>


Cheerz...
Denzil
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666