1

Much like this question in MySQL, I am trying to retain special characters such emojis into an nvarchar type column. However, any emojis are converted to "??". I have tried to reproduce the question's solution including changing column type and collation in SQL Server but haven't succeeded.

What I am attempting to do:

INSERT INTO TableName 
(Id, Title, Description) 
VALUES
(1, 'This is my title ','Here is a description with a  radio');

Where Title and Description columns are nvarchar(255).

The resulting insert looks like:

| Id | Title               | Description                           |
|----|---------------------|---------------------------------------|
| 1  | This is my title ?? | Here is a description with a ?? radio |

Using this to create the table

CREATE TABLE TableName(
  Id INT PRIMARY KEY,
  Title NVARCHAR(255),
  Description NVARCHAR(255)
);

The database's collation is SQL_Latin1_General_CP1_CI_AS

chandler
  • 71
  • 3
  • 9
  • While asking a question, you need to provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example): (1) DDL and sample data population, i.e. CREATE table(s) plus INSERT T-SQL statements. (2) What you need to do, i.e. logic and your code attempt implementation of it in T-SQL. (3) Desired output, based on the sample data in the #1 above. (4) Your SQL Server version (SELECT @@version;). – Yitzhak Khabinsky Nov 22 '22 at 15:03
  • 1
    Use a `N'Unicode literal'`. – Jeroen Mostert Nov 22 '22 at 15:14
  • 1
    Try: INSERT INTO TableName (Id, Title, Description) VALUES (1, N'This is my title ', N'Here is a description with a radio'); – Erwin Moller Nov 22 '22 at 15:15
  • Thanks! That was surprisingly easy – chandler Nov 22 '22 at 15:18

1 Answers1

2
    INSERT INTO TableName(Title,Description) 
    VALUES (N'      ⁉      ',
            N'      ⁉      ');

Use the prefix string literal with " N' <"my strange text"> ' "

Try this "select" statement as well:

    SELECT N'      ⁉      '
  • 1
    This looks like you've copied some of this from this [answer](https://stackoverflow.com/a/33938482/2029983), as the emoticons are *identical*. – Thom A Nov 22 '22 at 16:54