When user insert Russian word like 'пример' to database,database saves it like '??????'. If they insert with 'N' letter or I select it with 'N' letter, ie; exec Table_Name N'иытание' there is no problem. But I don't want to use 'N' in every query, so is there any solution for this? I will use stored procedure by the way.
UPDATE:
Now I can use Russian letters with alter collation. But I can't alter collation for every language and I just want to learn is there any trigger or function for automatic add N in front of the text after text add. IE; when I insert 'пример', SQL should take it like N'пример' autamaticly.
You have to use column's datatype NVARCHAR
to insert unicode letters, also you have to use N'value'
when inserting.
You can test it in following:
CREATE TABLE #test
(
varcharCol varchar(40),
nvarcharCol nvarchar(40)
)
INSERT INTO #test VALUES (N'иытание', N'иытание')
SELECT * FROM #test
OUTPUT
varcharCol nvarcharCol
??????? иытание
As you see column of datatype varchar
returning questionmarks ??????
and column of datatype nvarchar
returning russian characters иытание
.
UPDATE
Problem is that your database collation does not support russian letters.
MORE INFO
it would very difficult to put in comment i would recommend this link Info
declare @test TABLE
(
Col1 varchar(40),
Col2 varchar(40),
Col3 nvarchar(40),
Col4 nvarchar(40)
)
INSERT INTO @test VALUES
('иытание',N'иытание','иытание',N'иытание')
SELECT * FROM @test
RESULT
To store and select Unicode character in database you have to use NVARCHAR instead of VARCHAR. To insert Unicode data you have to use N
See this link https://technet.microsoft.com/en-us/library/ms191200%28v=sql.105%29.aspx
The n prefix for these data types comes from the ISO standard for National (Unicode) data types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With