22,207
社区成员
发帖
与我相关
我的任务
分享
WITH test(t) as (
SELECT CONVERT(NVARCHAR(30),N'中文') NAME UNION ALL
SELECT N'中文Abc' UNION ALL
SELECT N'中 文' UNION ALL
SELECT N'english' UNION ALL
SELECT N'Abc中文'
)
SELECT *
FROM test
WHERE t LIKE N'%[' +NCHAR(1)+ '-' +NCHAR(255)+ ']%'
t
------------------------------
中文Abc
中 文
english
Abc中文
-- 这两个函数,可以解决全角半角的问题。
select LEN('12345') , LEN('中国') ,datalength('12345') , datalength('中国')
----------- ----------- ----------- -----------
5 2 5 4
(1 行受影响)
with mt as (
select '中国' name union all
select '中国?' union all
select '中 国' union all
select 'x中国' union all
select '、中国'
)
select name , LEN(name) , datalength(name) from mt
where LEN(name) * 2 = datalength(name)
with mt as (
select '中国' name union all
select '中国?' union all
select '中 国' union all
select 'x中国' union all
select '、中国'
)
select name , LEN(name) , datalength(name) from mt
where LEN(name) * 2 = datalength(name)
with mt as (
select '中国' name union all
select '中国?' union all
select '中 国' union all
select 'x中国' union all
select '、中国'
)
select name , LEN(name) , datalength(name) from mt
where LEN(name) * 2 = datalength(name)
name
------ ----------- -----------
中国 2 4
、中国 3 6
(2 行受影响)
SELECT len(REPLACE( convert(VARCHAR, N'dddd'),'?',''))
SELECT len(REPLACE( convert(VARCHAR, N'中1国'),'?',''))
SELECT len(REPLACE( convert(VARCHAR, N'中国'),'?',''))
结果一次是4,1,0
WHERE len(REPLACE( convert(VARCHAR, colname),'?',''))>0