I have a problem with a special character inserted in a table of SQL Server 2008 R2. The point is that when i\'m trying to insert a string with the character º (e.g. 3 ELBO
when I run this:
print ascii('º')
I get 186 as the ascii code value, so try:
select * from YourTable Where Description like '%'+char(186)+'%'
to see all the ascii codes run this:
;WITH AllNumbers AS
(
SELECT 1 AS Number
UNION ALL
SELECT Number+1
FROM AllNumbers
WHERE Number<255
)
SELECT Number,CHAR(Number) FROM AllNumbers
OPTION (MAXRECURSION 255)
EDIT op stated in a comment that they are using nvarchar columns.
forger about ascii, use NCHAR (Transact-SQL) to output a degree symbol:
print '32'+NCHAR(176)+'F' --to display it
select * from YourTable
Where Description like '%'+NCHAR(176)+'%' --to select based on it
and use UNICODE (Transact-SQL) to get the value:
print UNICODE('°')
returns:
176