0
为什么在以下脚本中,charindex在SQL Server 2008 R2中返回的值不是0?nvarchar字段中的不可见字符?
--drop table #tmp
--go
create table #tmp (field1 nvarchar(50))
go
insert into #tmp values (N'Value 1')
go
insert into #tmp values (N'Value 2')
go
insert into #tmp values (N'Value 3')
go
DECLARE @i INT;
DECLARE @c NCHAR;
declare @nvc nvarchar(50) = N'Test Value';
SET @i = 128;
WHILE @i < 256
BEGIN
SET @i = @i + 1;
SET @c = nchar(@i);
if exists (select 1 from #tmp t where charindex (@c, t.field1) > 0)
print @c;
END
在我的分贝实例产生的输出(使用归类:SQL_Latin1_General_CP1_CI_AS):
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
²
³
¹