Dear All,
I have a stored procedure where I have a variable that will be English or Arabic string, for Arabic string I need to add prefix N to the variable.
declare @ModuleName nvarchar(max)
set @ModuleName = 'أساسيات الكمبيوتر'
SELECT * FROM Module WHERE NameEN LIKE N'%' + @ModuleName + '%' OR NameAR LIKE '%' + @ModuleName + '%'
What I have tried:
Create function fnGetModuleIDByModuleName
(@ModuleName nvarchar(max))
returns int
begin
declare @ModuleID int
SELECT @ModuleID = ID FROM Module where NameEN like '%' + @ModuleName + '%' or NameAR like '%' + @ModuleName + '%'
return @ModuleID
end
Calling function
declare @m nvarchar(max)
set @m = 'أساسيات الكمبيوتر'
select dbo.fnGetModuleIDByModuleName(@m)
if I add prefix N to the string then it will work
declare @m nvarchar(max)
set @m = N'أساسيات الكمبيوتر'
select dbo.fnGetModuleIDByModuleName(@m)
I can't hardcode any variable, the variable value is coming from the parameter of the stored procedure. So, my question is, how can I add prefix N to the @variable?
Can anyone please help me.
Thanks in advance