Here is the code:

CREATE TABLE [dbo].[Employees] ( [Id] INT IDENTITY(1,1) NOT NULL, [Name] VARCHAR (30) NOT NULL, [Surname] VARCHAR (30) NOT NULL, [Patronymic] VARCHAR (30) NULL, [DateofBirth] DATE NOT NULL, [Address] VARCHAR (160) NOT NULL, [Position] INT NOT NULL, [Surcharge] INT NULL, --надбавка PRIMARY KEY ([Id] ) ); 

And so what happens: The problem depicted in the gif-ke

When filling the table, if you write in Cyrillic, the characters turn into a question mark. I tried to change VARCHAR to NVARCHAR, but it did not help.

    2 answers 2

    I tried to change VARCHAR to NVARCHAR, but it did not help.

    The step is correct, but this is not enough, we know that the types are different in that NVARCHAR can store UNICODE , but it does not convert the data when inserted into UNICODE .

    Change the column types:

     CREATE TABLE Employees ( [Id] INT IDENTITY(1,1) NOT NULL PRIMARY KEY, [Name] NVARCHAR (30) NOT NULL, [Surname] NVARCHAR (30) NOT NULL, [Patronymic] NVARCHAR (30) NULL, [DateofBirth] DATE NOT NULL, [Address] NVARCHAR (160) NOT NULL, [Position] INT NOT NULL, [Surcharge] INT NULL --надбавка ); 

    And add N ( N'Petrov ' ) to the string values, thereby converting the data when inserted into UNICODE .

     INSERT Employees ([Name],[Surname],[Patronymic],[DateofBirth],[Address],[Position],[Surcharge]) VALUES (N'Иван',N'Федоров',N'Петрович',GETDATE(),N'Где-то там',1,0) 

    Here are the signs ????? more will not torment you)

    More details:

    The Unicode character constant prefix with the letter N indicates the input UCS-2 or UTF-16, depending on whether the SC sort is used or not. Without the N prefix, the string is converted to a default code page, which may not recognize certain characters.

    And the link to the article itself: nchar and nvarchar

    • Thank. Works. - Edward

    Add DEFAULT CHARACTER SET (and - for correct sorting - also DEFAULT COLLATE ):

     CREATE TABLE [dbo].[Employees] ( [Id] INT IDENTITY(1,1) NOT NULL, [Name] VARCHAR (30) NOT NULL, [Surname] VARCHAR (30) NOT NULL, [Patronymic] VARCHAR (30) NULL, [DateofBirth] DATE NOT NULL, [Address] VARCHAR (160) NOT NULL, [Position] INT NOT NULL, [Surcharge] INT NULL, --надбавка PRIMARY KEY ([Id] ) ) DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; 
    • one
      There is no such syntax in MS SQL, nor such COLLATE. - Denis Rubashkin