function - "N" before text in sql server -


i have function

create function [dbo].[persiannum] ( @persionstr nvarchar(255) ) returns nvarchar(255)  begin declare @out nvarchar(255) -- code  return @out end 

and call : " select dbo.persiannum (n'۰۸/۰۲/۲۰۱۶ ۱۰:۱۳:۵۵') " line worked correctly.

now wanted call in trigger '۰۸/۰۲/۲۰۱۶ ۱۰:۱۳:۵۵' in @myinput

 select dbo.persiannum (@myinput) 

but need " n " before input how put before @myinput

alter function [dbo].[persiannum] ( @persionstr nvarchar(255) ) returns nvarchar(255) --۰۸/۰۲/۲۰۱۶ ۱۰:۱۴:۴۴ ۰۸/۰۲/۲۰۱۶ ۱۰:۱۳:۵۵ begin declare @out nvarchar(255) declare @ss nvarchar(255) declare @persiantemp nvarchar(255) declare @len int  set @len = len(@persionstr)    set @persiantemp= @persionstr   set @out='' while @len>0   begin set @len=@len-1;  set @ss = substring(@persiantemp, 1, 1) set @persiantemp=substring(@persiantemp, 2, @len) set @out=@out+ case @ss when n'۰' n'0' when n'۱' n'1' when n'۲' n'2' when n'۳' n'3' when n'۴' n'4' when n'۵' n'5' when n'۶' n'6' when n'۷' n'7' when n'۸' n'8' when n'۹' n'9'  else @ss end   end             return @out end 

this complete function

the n used cast string nvarchar, once string nvarchar don't need cast again. need define @myinput nvarchar otherwise persian text not encoded correctly.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -