In order to store non English characters in the SQL serevr tables, you need to declare column/variable with an Unicode supported datatypes which are NCHAR, NVARCHAR or NTEXT. Also, while inserting the data, you need to prefix N in front of the data to make SQL Server aware that, you're following characters are Unicode characters.
Placing an example here for using non English character in SQL server. You can see that statement that has not prefix N has inserted Unicode characters as "????".
DROP TABLE #temp
Placing an example here for using non English character in SQL server. You can see that statement that has not prefix N has inserted Unicode characters as "????".
create table #temp (body nvarchar(20))
insert into #temp (body) SELECT '汉字/漢字'
select * from #temp
insert into #temp (body) SELECT N'汉字/漢字'
select * from #temp
declare @string1 nvarchar(20) = '汉字/漢字'
insert into #temp (body) SELECT
@string1
select * from #temp
declare @string2 nvarchar(20) = N'汉字/漢字'
insert into #temp (body) VALUES (@string2)
select * from #temp
No comments:
Post a Comment