Sql server 查询字符串中的中文

DECLARE @s NVARCHAR(50) =N’013w23是是是1233是123是123’;
SELECT CASE WHEN ISNUMERIC(LEFT(@s, 1))=0 THEN @s
WHEN ISNUMERIC(LEFT(@s, 2))=0 THEN SUBSTRING(@s, 2, LEN(@s))
WHEN ISNUMERIC(LEFT(@s, 3))=0 THEN SUBSTRING(@s, 3, LEN(@s))
WHEN ISNUMERIC(LEFT(@s, 4))=0 THEN SUBSTRING(@s, 4, LEN(@s))
WHEN ISNUMERIC(LEFT(@s, 5))=0 THEN SUBSTRING(@s, 5, LEN(@s))
WHEN ISNUMERIC(LEFT(@s, 6))=0 THEN SUBSTRING(@s, 6, LEN(@s))
WHEN ISNUMERIC(LEFT(@s, 7))=0 THEN SUBSTRING(@s, 7, LEN(@s))
WHEN ISNUMERIC(LEFT(@s, 8))=0 THEN SUBSTRING(@s, 8, LEN(@s))
WHEN ISNUMERIC(LEFT(@s, 9))=0 THEN SUBSTRING(@s, 9, LEN(@s))
WHEN ISNUMERIC(LEFT(@s, 10))=0 THEN SUBSTRING(@s, 10, LEN(@s))END,
CASE WHEN ISNUMERIC(LEFT(@s, 1))=0 THEN @s
WHEN ISNUMERIC(LEFT(@s, 2))=0 THEN SUBSTRING(@s, 1, 1)
WHEN ISNUMERIC(LEFT(@s, 3))=0 THEN SUBSTRING(@s, 1, 2)
WHEN ISNUMERIC(LEFT(@s, 4))=0 THEN SUBSTRING(@s, 1, 3)
WHEN ISNUMERIC(LEFT(@s, 5))=0 THEN SUBSTRING(@s, 1, 4)
WHEN ISNUMERIC(LEFT(@s, 6))=0 THEN SUBSTRING(@s, 1, 5)
WHEN ISNUMERIC(LEFT(@s, 7))=0 THEN SUBSTRING(@s, 1, 6)
WHEN ISNUMERIC(LEFT(@s, 8))=0 THEN SUBSTRING(@s, 1, 7)
WHEN ISNUMERIC(LEFT(@s, 9))=0 THEN SUBSTRING(@s, 1, 8)
WHEN ISNUMERIC(LEFT(@s, 10))=0 THEN SUBSTRING(@s, 1, 9)END,
SUBSTRING(@s, 1, PATINDEX(‘%[啊-在]%’, @s)-1);
这个啊和在 是代表查啊(a)到在(z)之前的中文 找到第一个中文然后截取

你可能感兴趣的:(笔记,sql)