SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to order a column logic
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

insanepaul
Posting Yak Master

172 Posts

Posted - 04/12/2012 :  10:58:26  Show Profile  Reply with Quote
These are strings in the table under column xmlTransaction and they can be in any order:

<Person update >
<Person insert >
<CPAdress update >
<CPAdress insert >
<Person update >
<Person insert >
<CPAdress update >
<CPAdress insert >

I always need all the <Person insert > to be at the top and
It doesn't matter about the others.

If I order by xmlTransaction I get CPAdress before Person
If I order by xmlTransaction desc I get Person update

I could just get the Person Inserts then the person updates then CPAaddress but thats a bit of an effort and I don't know how to escape the = and quote marks as the full string is:
<Person ActionType="Insert"

Edited by - insanepaul on 04/12/2012 11:25:52

russell
Pyro-ma-ni-yak

USA
4965 Posts

Posted - 04/12/2012 :  11:26:29  Show Profile  Visit russell's Homepage  Reply with Quote
quote:
Originally posted by insanepaul

I always need all the <Person insert > to be at the top and
It doesn't matter about the others.



ORDER BY CASE WHEN xmlTransaction like '<Person Insert%' THEN 0 ELSE 1 END
Go to Top of Page

insanepaul
Posting Yak Master

172 Posts

Posted - 04/12/2012 :  11:32:22  Show Profile  Reply with Quote
Thanks for the help
Go to Top of Page

russell
Pyro-ma-ni-yak

USA
4965 Posts

Posted - 04/12/2012 :  12:26:57  Show Profile  Visit russell's Homepage  Reply with Quote
You're welcome. :)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000