select SUBSTRING('hello 世田谷区経堂世田谷区経堂 ',5,10) as Japanese
gives output as "o ????????".

Is there any way i can get the substring of above string ?
Thanks in advance for your help.

Edited 2 Years Ago by arunkumars

Attachments Substring.png 4.43 KB

Found this myself, but still need some help

SUBSTRING(N’世田谷区経堂世田谷区経堂’,5,6) will give the expected result, but since am writing a function to handle such cases, am not able to get this declared variables.
Ex : Substring(N'['+@Temp+']').
How do i use N here ?
Any help appreciated.

@Temp is an NVarChar?

Is this part of a Dynamic Sql Statement?

Please can you supply more of the query

DECLARE @TEMP NVARCHAR(100)
SET @TEMP = 'hello 世田谷区経堂世田谷区経堂'
SET @TEMP = 'N'''+@TEMP
Select SUBSTRING(@TEMP,5,10)

Am just trying to pass the variable @TEMP to substring, but doesnt work,

actually am trying this in a scalar valued function to handle such cases.

Click Here

This article should help you understand the problem.

with the current collation settings on your database the above query should return llo ??????

Edited 2 Years Ago by Fenrir()

Collation by default for the column is LatinSQL, but since this column data may be any language, changing this would not be an option.
am not able to concatenate N and @TEMP, this is my issue now.

This article has been dead for over six months. Start a new discussion instead.