How to insert special characters/superscript into SQL Server using Entity Framework?

vsdwdz23  于 2023-11-16  发布在  SQL Server
关注(0)|答案(1)|浏览(131)

I have a web application using entity framework to read and update a database. The data being entered into the database can contain a range of different characters such as superscript and characters like this: β.

They are not saving into the database correctly - they are displaying like as follows: cm3.

The column is already a NVarChar and the database collation is Latin1_General_CI_AS.

I expect the text to be exactly the same as what was entered.

yqlxgs2m

yqlxgs2m1#

You can simple use the Unicode method Example:= SELECT cast(N'Abhinandᵀᴹ' as nvarchar) AS Sample

nvarchar converts string into Unicode so a way to use a superscript is to putting it into a Unicode

note use the capital N before your string or text, otherwise it won't show

相关问题