HTML Symbols are being displayed as a question mark in SQL Server Database

人走茶凉 提交于 2019-12-05 05:59:33

You need to use NVARCHAR datatype for your column, VARCHAR datatype can only be use for non-unicode character.

if you are storing unicode characters in your datatype you should use NVARCHAR datatypes and when inserting Data into your Column use the N prefix telling sql server there will be some unicode characters in the passed string.

With VARCHAR DataType

CREATE TABLE #Temp (Column1 VARCHAR(100))
INSERT INTO #Temp VALUES('★')
SELECT * FROM #Temp

Result

╔═════════╗
║ Column1 ║
╠═════════╣
║ ?       ║
╚═════════╝

With NVARCHAR DataType

CREATE TABLE  #Tempn (Column1 NVARCHAR(100) )
INSERT INTO #Tempn VALUES(N'★')        --<-- N prefix for Unicode Characters
SELECT * FROM #Tempn

Result

╔═════════╗
║ Column1 ║
╠═════════╣
║ ★       ║
╚═════════╝

Define the symbol as an NVARCHAR instead of a VARCHAR

insert into tablename values (N'★ ') 

above is the syntax for inserting and make sure your field data type is nvarchar or try this test example

create table test (abc nvarchar)
insert into test values (N'★ ')
 select * from test
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!