martyje
asked on
How to sort an nvarchar field that contains special characters
I am trying to sort a field that has special characters in them .i.e. `, ", ' etc
When I sort the results, the records with special characters always show up first, is there any way to ignore special characters during the sort, in SQL Server maybe? or in PHP if not.
Thanks.
When I sort the results, the records with special characters always show up first, is there any way to ignore special characters during the sort, in SQL Server maybe? or in PHP if not.
Thanks.
.i.e. `, ", ' etc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
single quotes:
replace(fieldname, '''', '')
double quotes:
replace(fieldname, '''''', '')
replace(fieldname, '''', '')
double quotes:
replace(fieldname, '''''', '')
ASKER
Sorry guys, I have to keep the single qoutes/double qoutes and all the speical characters in there and then sort it. Is there any way to not to take them out but ignore them while sorthing.
Thanks much.
Thanks much.
You're not taking them out...you're just taking them out of the sort....just like angelIII showed you. You're ignoring them....make sure your REPLACE statement is after the ORDER BY clause.
ASKER
You rock... Thanks much.
ASKER
It works fine with ` but gives error on double qoutes and single qoutes.
Thanks much.