I have query like that in my DataSet (database is located in .mdf file):
我的数据集中有这样的查询(数据库位于。mdf文件中):
SELECT *
FROM TableName
WHERE SomeField LIKE @Param
Table TableName
contains record Значение
in SomeField
field.
表的表包含记录ЗначениеSomeField领域。
When @Param
is Значени%
it's works perfectly, but when @Param
is Значен%
or Значе%
, it's returns 0 rows. Значе%%%
also works.
当@ParamЗначени%它完美的作品,但@ParamЗначен%或Значе%时,它返回0行。Значе% % %同样适用。
Why '%' works as single-character wildcard?
为什么“%”是单字符通配符?
1 个解决方案
#1
5
Your problem is that you should be using @param of NVARCHAR, not NCHAR
您的问题是您应该使用NVARCHAR的@param,而不是NCHAR。
declare @Param nchar(255)
set @Param = N'Значе%'
This is really
这真的是
N'Значе% ...' (many more spaces)
So it won't match your data, which is
所以它不会匹配你的数据
N'Значение ...' (padded with spaces)
#1
5
Your problem is that you should be using @param of NVARCHAR, not NCHAR
您的问题是您应该使用NVARCHAR的@param,而不是NCHAR。
declare @Param nchar(255)
set @Param = N'Значе%'
This is really
这真的是
N'Значе% ...' (many more spaces)
So it won't match your data, which is
所以它不会匹配你的数据
N'Значение ...' (padded with spaces)