I have a user profile(more than one profile based on user type) which I'm storing in a DB column(xml).
I can query on this using XPATH in my stored procedure, however I am unsure how to then perform an ORDER BY.
SELECT U.UserId, UP.Profile, UP.UserParentID
FROM aspnet_Users U
LEFT OUTER JOIN UserProperties UP ON U.UserId = UP.UserId
WHERE
UP.Profile.exist('/Properties/property[contains(.,sql:variable("@cLookup"))]') = 1
Example XML:
<Properties>
<property id="BusinessName" name="Business Name"></property>
<property id="AccountNumber" name="Account Number"></property>
<property id="Address" name="Address"></property>
<property id="Phone" name="Phone"></property>
<property id="Fax" name="Fax"></property>
<property id="Web" name="Web"></property>
<property id="ABN" name="ABN"></property>
<property id="Logo" name="Logo"></property>
<property id="Photos" name="Photos"></property>
<property id="Map" name="Location Map"></property>
</Properties>
AND
<Properties>
<property id="FirstName" name="First Name"></property>
<property id="LastName" name="Last Name"></property>
</Properties>
Would want to ORDER BY BusinessName