Determine if the SQL contains Chinese characters-----to be verified

Source: Internet
Author: User

SELECT * FROM table name where column name like '%[acridine-seat]% '

II. include English characters

SELECT * FROM table name where column name like '%[a-z]% '

Third, contains the pure digital

SELECT * FROM table name where column name like '%[0-9]% '

MSSQL Determines whether the field contains Chinese characters

Find records that contain Chinese characters
SELECT * from [table name] where not PATINDEX ('%[-do]% ', [Field name]) =0
find records that do not contain Chinese characters
SELECT * from [table name] where PATINDEX ('%[-do]% ', [Field name]) =0 function:

CREATE FUNCTION [dbo]. [UDF_ISCONTAINCHINESE_BY_SLU]
(@inString nvarchar (1000))
RETURNS int
As
BEGIN

DECLARE @flag int
DECLARE @valueLength int
SET @valueLength = LEN (@inString)

DECLARE @i int

SET @i = 1
While @valueLength >= @i
BEGIN
DECLARE @ChcekValue int
SELECT @ChcekValue = ASCII (SUBSTRING (@inString, @i,1))
--select @ChcekValue

if (@ChcekValue > 122)
BEGIN
--With Chinese
SET @flag = 1
--Jump out
Break
END
ELSE
BEGIN

SET @flag = 0
END

SET @i = @i +1
END

RETURN @flag

END

/*****************************************/

--sql Determines whether the field value has Chinese
Create function fun_getcn (@str nvarchar (4000))
returns nvarchar (4000)
as
begin
D Eclare @word nchar (1), @CN nvarchar (4000)
Set @CN = '
while Len (@str) >0
begin
Set @word =left (@str, 1)
If Unicode (@word) between 19968 and 19968+20901
Set @[email protected][email protected]
Set @str = Right (@str, Len (@str)-1)
End
Return @CN
End
Select DBO.FUN_GETCN (' asdkg forum KDL ')
--Forum
Select DBO.FUN_GETCN (' asdkg theory Altar kdl ')
--Altar
Select DBO.FUN_GETCN (' ASDKDL ')
--null

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.