--"Extract Chinese"
IF object_id (' DBO.FUN_GETCN ') is not NULL
DROP FUNCTION DBO.FUN_GETCN
GO
Create function DBO.FUN_GETCN (@str varchar (4000))
Returns varchar (4000)
As
Begin
DECLARE @word nchar (1), @CN varchar (4000)
Set @CN = ' '
While Len (@str) >0
Begin
Set @word =left (@str, 1)
If Unicode (@word) between 19968 and 40869
Set @[email Protected][email protected]
Set @str =right (@str, Len (@str)-1)
End
Return @CN
End
GO
SELECT DBO.FUN_GETCN (' Turing me 666QQ Chinese AK123 ')
--"Extract Chinese"
IF object_id (' Dbo.get_chinese ') is not NULL
DROP FUNCTION Dbo.get_chinese
GO
CREATE FUNCTION Dbo.get_chinese (@S NVARCHAR (100))
RETURNS VARCHAR (100)
As
BEGIN
While PATINDEX ('%[^-seat]% ', @S) > 0
SET @S = STUFF (@s,patindex ('%[^ acridine-block]% ', @S), 1,n ')
RETURN @S
END
GO
SELECT Dbo.get_chinese (' Turing me 666QQ Chinese AK123 ')
--"extract numbers"
IF object_id (' dbo. Get_number ') is not NULL
DROP FUNCTION dbo. Get_number
GO
CREATE FUNCTION dbo. Get_number (@S VARCHAR (100))
RETURNS VARCHAR (100)
As
BEGIN
While PATINDEX ('%[^0-9]% ', @S) > 0
BEGIN
Set @s=stuff (@s,patindex ('%[^0-9]% ', @s), 1, ')
END
RETURN @S
END
GO
SELECT DBO. Get_number (' Turing me 666QQ Chinese AK123 ')
--"extract English"
IF object_id (' dbo.get_english ') is not NULL
DROP FUNCTION Dbo.get_english
GO
CREATE FUNCTION dbo.get_english (@S VARCHAR (100))
RETURNS VARCHAR (100)
As
BEGIN
While PATINDEX ('%[^a-z]% ', @S) > 0
BEGIN
Set @s=stuff (@s,patindex ('%[^a-z]% ', @s), 1, ')
END
RETURN @S
END
GO
SELECT dbo.get_english (' Turing me 666QQ Chinese AK123 ')
SQL Server extracts Chinese, English, and digital from a string