Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

� IN SQL Server database

in my database I have this char �. I want to locate them with a query

Select * 
from Sometable 
where somecolumn like '%�%'

this gets me no result.

I think it is ANSI encoding

like image 587
Simon Avatar asked Apr 18 '17 14:04

Simon


People also ask

Why * is used in SQL?

The second part of a SQL query is the name of the column you want to retrieve for each record you are getting. You can obviously retrieve multiple columns for each record, and (only if you want to retrieve all the columns) you can replace the list of them with * , which means "all columns".

What are the 4 system databases in SQL Server?

SQL Server provides four system databases including master , msdb , model , and tempdb .

What does <> mean in SQL Server?

<> operator means not equal to in MS SQL. It compares two expressions (a comparison operator). When you compare nonnull expressions, the result is TRUE if the left operand is not equal to the right operand; otherwise, the result is FALSE. If either or both operands are NULL, see the topic SET ANSI_NULLS (Transact-SQL).

What are the 3 types of database?

hierarchical database systems. network database systems. object-oriented database systems.


1 Answers

use N like below

 where col like N'%�%'

why do you think ,you need N prefix:

Prefix Unicode character string constants with the letter N. Without the N prefix, the string is converted to the default code page of the database. This default code page may not recognize certain characters.

Thanks to Martin Smith,Earlier i tested only with one character earlier and it worked,but as Martin pointed out, it returns all characters..

Below query works and returns only intended

select * from #demo where id  like N'%�%' 
COLLATE Latin1_General_100_BIN

Demo:

create table #demo
(
id nvarchar(max)
)

insert into #demo
values
(N'ﬗ'),
( N'�')

to know more about unicode,please see below links

http://kunststube.net/encoding/

https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/

like image 129
TheGameiswar Avatar answered Oct 26 '22 18:10

TheGameiswar