在SQL语句中,如何判断汉字和字符?

来源:互联网 发布:淘宝怎样能排名靠前 编辑:程序博客网 时间:2024/06/18 07:46
oracle中:
------------
SQL> create table test(a varchar2(10));

Table created.

SQL> insert into test values('鸟');

1 row created.

SQL> commit;

Commit complete.

SQL> insert into test values('深刻');

1 row created.

SQL> commit;

Commit complete.

SQL> insert into test values('aaa');

1 row created.

SQL> insert into test values('bbb');

1 row created.

SQL> commit;

Commit complete.

SQL> select a from test;

A
----------

深刻
aaa
bbb

SQL> select a from test where asciistr(a) like '%\%';

A
----------

深刻

SQL> select a from test where asciistr(a) not like  '%\%';

A
----------
aaa
bbb
 
select a,asciistr(a) from test where asciistr(a) like '%\%';

A          ASCIISTR(A)
---------- --------------------------------------------------
鸟         \FFFD\FFFD
深刻       \FFFD\FFFD\FFFD\FFFD
 
----------------------------------------------------------------------------------------------------------------------
sql中:
--------
declare @t table([Name] nvarchar(10))
insert @t select '好的啊!'
insert @t select '12345好的'
insert @t select '123'
insert @t select 'sdff'
select * from @t where PATINDEX('%[吖-座]%',[name])>0
/*
Name       
---------- 
好的啊!
12345好的

(所影响的行数为 2 行)*/
------------------------------------------------------------
PATINDEX('%[吖-座]%',[name])>0
0 0
原创粉丝点击