當前位置:首頁 » 編程語言 » sql判斷中文
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

sql判斷中文

發布時間: 2022-08-15 21:41:06

1. 求sql語句,怎樣查詢一個表中都是漢字的記錄

判斷每個字元是否處在中文的區間(unicode range).

如果你的資料庫字元集與環境變數都是中文字元集, 可以使用一個簡單的辦法判斷一個欄位是否含有ascii7的字元, 基本上可以認為這個欄位是否含有中文字元.

2. sql查詢所有包含中文的數據

判斷length(content)和lengthb(content)是否相等,如果不相等則包含中文,否則全英文。
length(content)計算content的字元個數,一個中文字元長度為1;
lengthb(content)計算content的位元組位數,一個位長度為1,一個中文字元長度為2。

1樓說的不對

3. SQL資料庫查詢使用正則表達式如何查詢中文

我不知道這算不算sql的正則表達式,它只模糊查詢但是可以達到正則表達式的效果select * from shop_yw where name2 between '李明' and '張明'select * from shop_yw where name2 like '%李%'select * from shop_yw where name2 like '[李明-張立]'select * from shop_yw where name2 like '[a-z]'select * from shop_yw where name2 like '-['李','趙']'select * from shop_yw where name2 like '[^a-f]'

4. 在sql中兩個中文字元串怎麼判斷相似百分比

文本比較的核心就是比較兩個給定的文本之間的差異.目前,主流的比較文本之間的差異主要有兩大類.一類是基於編輯距離的,例如LD演算法.一類是基於最長公共子串的,例如Needleman/Wunsch演算法等
LD演算法又成為編輯距離演算法,他是以字元串A通過插入字元、刪除字元、替換字元變成另一個字元串B,那麼操作的過程的次數表示兩個字元串的差異
以下是SQL版本的LD演算法代碼
Create Function [dbo].[LD](@Str1 Varchar(8000),@Str2 Varchar(8000))
Returns Numeric(18,3)
As
Begin
Declare @I int
Declare @J int
Declare @A int
Declare @B int
Declare @C int
Declare @K int
Declare @Rst Numeric(18,3)

Declare @Matrix Table (i int,j int,val int)

Insert into @Matrix Values(0,0,0)
Set @i=1
While @i<=Len(@Str1)
Begin
insert into @Matrix Values(@i,0,@i)
Set @I=@I+1
End

Set @j=1
While @j<=Len(@Str2)
Begin
insert into @Matrix Values(0,@j,@j)
Set @j=@j+1
End

Set @i=1
While @I<=Len(@Str1)
Begin
Set @j=1
While @J<=Len(@Str2)
Begin
If (substring(@Str1, (Select Val From @Matrix Where i=0 And j=@j), 1) = substring(@Str2, (Select Val From @Matrix Where i=@I And j=0), 1))
Select @C =Val From @Matrix Where i=@i-1 And j=@j - 1
Else
Select @C =Val+1 From @Matrix Where i=@i-1 And j=@j - 1

Select @A =Val+1 From @Matrix Where i=@i - 1 And j=@j
Select @B =Val+1 From @Matrix Where i=@i And j=@j-1

If (@A <= @B and @A <= @C)
Insert Into @Matrix Values( @i,@j,@A)
If (@B <= @C and @B <= @A)
Insert Into @Matrix Values( @i,@j,@B)
If (@C <= @A and @C <= @B)
Insert Into @Matrix Values( @i,@j,@C)
Set @J=@J+1
End
Set @I=@I+1
End

If Len(@Str1) > Len(@Str2)
Set @K = Len(@Str1)
Else
Set @K = Len(@Str2)
Select @Rst=1-1.0*Max(Val)/@K From @Matrix Where i= Len(@Str1) And j= Len(@Str2)
return @Rst
End

5. sqlserver如何判斷欄位中是否含有漢字

--/*

--unicode編碼范圍:

--漢字:[0x4e00,0x9fa5](或十進制[19968,40869])

--數字:[0x30,0x39](或十進制[48,57])

--小寫字母:[0x61,0x7a](或十進制[97,122])

--大寫字母:[0x41,0x5a](或十進制[65,90])

--根據編碼范圍來判斷

--*/
--創建

createprocp_A_VIC

as

declare@countint

declare@iint

declare@textnvarchar(50)

set@i=0

set@count=(selectCOUNT(*)fromtable)

while(@i<@count)

begin

set@i+=1
--sid代表有一定循環規律的,若是無序的可以添加一個序列(Row_Number()OVER---)。
--select*from(SELECT*,Row_Number()OVER(ORDERBY[sid])numFROMs--table)asswherenum=3
set@text=(selectafromtablewhere[sid]=@i)

ifunicode(@text)between19968And40869orunicode(@text)between97And122orunicode('a')between65And90

begin

print0

end

else

print@text

end

--執行

execp_A_VIC

6. 怎樣用sql語言判斷中文欄位是否相等

SLQ:
select * from test where ClassID in
(select classid from
(select classid,mark from test group by classid,mark)
group by classid
having COUNT(classid)=1)
and Mark=2

其結第4、5、6行classid都相同且mark2其實太明白要求查詢結麽希望想要...!

7. SQL 判斷欄位值是否有中文

實現思路:漢字的Unicode是用「\」開始的,這個是與其它字元的區別。

sql: select * from tablename where asciistr(columnTest) like '%\%';

備註:這個asciistr就是字元轉Unicode的方法,記住用法就可以了。

8. Oracle中如何用SQL檢測欄位是否包括中文字元

select * from table where regexp_like(欄位,'[^[:alphanum:]]')
這句話的意思是顯示在table表的欄位中不包含a-z,A-Z,0-9字元的欄位。除了這些意外能包含的字元基本上只有漢字和標點符號,但是如果你的資料庫是多文字版本的,比如裡面有日語,法語德語等語言,那麼這個就不好使了。

9. sql 查詢語句查詢中文名稱

select * from table where [企業名稱]='浙江'

10. MSSQL中怎麼判斷欄位值是日語還是中文另怎麼將日語轉換成羅馬拼音呢

select * from tb where patindex('%[吖-座]%',col) > 0 判斷是中文(繁體版下可能會碰到麻煩)
數字是[0-9],字母是[a-z]
日文不會

如果你是做多國語言,那還是不要在資料庫來做了,在XML文件配置一下吧