Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2012 not showing unicode character in results

All I want to do is update a field with the DIRECT CURRENT SYMBOL FORM TWO character into my SQL Server 2012 database. Is that too much to ask? Apparently it is.

The answer to this question and this question is the same and did not work for me.

My update script

UPDATE Table 
SET Value = N'SUPPLY 9-30Vdc 0.2W ⎓' 
WHERE id = '1234'

Aaaaand the relevant table schema:

CREATE TABLE [dbo].[Table]
(
    ...
    ... 
    [Value] [nvarchar] (1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    ...
    ...
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

Want more? Here's the results of sp_columns:

enter image description here

Yes, I prefixed the string with N''. That should work, right? Nope.

Screenshot:

enter image description here

Notice the little box where the unicode character should be. Why, though?

like image 624
LCIII Avatar asked Mar 11 '23 23:03

LCIII


2 Answers

Per the comment discussion on your question, your SQL code is correct and the unicode character is being updated, but SQL Server Management Studio cannot (for some reason) display this unicode character in the GRID resultset. If you change your result view to TEXT (control+T), you should see the unicode character.

"If you use SSMS for your queries, change to output type from "Grid" to "Text", because depending on the font the grid can't show unicode."

  • sql server 2008 not showing and inserting unicode characters
like image 196
Aron Avatar answered Mar 25 '23 06:03

Aron


Thanks to @Aron, I was having next problem:

In SSMS, when I copy a text like Sighișoara from a grid result (table A from database A) and paste in an insert query (table B from database B), the result of this insert was Sighi?oara, with an interrogation character.

Steps that helped to me in SSMS:

  1. Tools --> Options --> Environement --> Fonts and Colors. Select in Show settings for the option Grid Results and for this option, use an unicode font.
  2. Be sure that your table has the column with nvarchar(X), not varchar(X).
  3. Be sure that, when you insert data, you have N character before string, like this:

    insert into table(a,b,c,d,e,f) values ('Rumania',N'Sighișoara',GETDATE(),0,0,'Test')

(For SSMS 17.9.1)

like image 33
Dani Avatar answered Mar 25 '23 04:03

Dani