在将Clause传递给SP时,Sql server不搜索Unicode [英] Sql server not searching Unicode while passing where Clause to SP
本文介绍了在将Clause传递给SP时,Sql server不搜索Unicode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在sql中进行unicode搜索任务但面临问题。只是当我使用查询进行搜索时它工作得非常好
I am doing unicode searching task in sql but facing problem۔ simply when i doing search using query it is working very fine
select Hadith_Urdu
from Hadiths_old
where Hadith_Urdu like N'%حماد%'
以上查询搜索了超过1600条记录
而
使用存储过程它显示我不是一条记录。我正在通过cla 使用到SP
我的SP执行与Where子句参数是下面给出
above query searched more then 1600 records
while
using store procedure it is showing me not a single record. I am passing where clause to SP
my SP execution with Where clause Parameter is below give
execute SPSearching @Mode ='Searching', @WhereClause= 'Hadith_Urdu Like N''%حماد%'''
和我的SP低于
and my SP is below
USE [SSDB2]
ALTER PROCEDURE [dbo].[SPSearching]
-- Add the parameters for the stored procedure here
@Mode varchar(50),
@WhereClause Nvarchar(Max) = null
AS
if @Mode= 'ColumnNames'
BEGIN
SELECT column_name FROM information_schema.columns WHERE table_name = 'Hadiths_old'
END
if @Mode= 'Searching'
BEGIN
declare @SQL VARCHAR(MAX)
SET @SQL='Select [Hadith_Text]
,[Hadith_Urdu]
,[Hadith_English]
,[Chapter_English_Name]
,[Chapter_Urdu_Name]
,[Baab_English_Name]
,[Baab_Urdu_Name]
,[Baab_Id]
,[Hadith_Book_Number]
From Hadiths_old
Where '
IF @WhereClause<>''
SET @SQL=@SQL+' '+ @WhereClause + ' order by ID'
EXEC(@SQL)
END
推荐答案
替换VARCHAR
带<的变量code> NVARCHAR 。VARCHAR
适用于非unicode。
请参阅:
char和varchar(Transact-SQL) [ ^ ]
nchar和nvarchar(Transact-SQL) [ ^ ]
ReplaceVARCHAR
variable withNVARCHAR
.VARCHAR
is for non-unicode.
Please, see:
char and varchar (Transact-SQL)[^]
nchar and nvarchar (Transact-SQL)[^]
这篇关于在将Clause传递给SP时,Sql server不搜索Unicode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文