March 5, 2018 at 5:42 am
Changed one of the existing column datatype from varchar(250) to nvarchar(250) but the column still showing arabic characters as ??
How can i resolve this?
March 5, 2018 at 6:19 am
We need a lot more detail. It appears likely that the data you have is not standard English characters, but just changing a datatype from varchar to nvarchar only provides the means to store unicode characters. As the column was varchar at the time it was populated, if there were unicode characters being used, then such characters were likely converted, possibly implicitly, at the time the data was inserted or updated into the table, and one of the possible consequences is that information got lost in that conversion. You'll need to provide more specific details and as much specific history of events as you can in order for someone to be able to help much. One other possibility is that you just have foreign language characters, and you may just need to set the proper collation for that column, but that seems a lot less likely.
Steve (aka sgmunson) 🙂 🙂 🙂
Rent Servers for Income (picks and shovels strategy)
March 5, 2018 at 6:33 am
VastSQL - Monday, March 5, 2018 5:42 AMChanged one of the existing column datatype from varchar(250) to nvarchar(250) but the column still showing arabic characters as ??How can i resolve this?
As Steve mentioned, once the data is saved or converted into varchar, there's no way to get the unicode data back.
If after the data type change, you still can't store the arabic characters correctly, you need to check your string handling. Here's an example of what I mean.
DECLARE @test-2 TABLE( MyString nvarchar(250));
INSERT INTO @test-2 VALUES('طالÙٱئذش'); --Random string without any knowledge on what it means
INSERT INTO @test-2 VALUES(N'طالÙٱئذش');
SELECT *
FROM @test-2;
March 6, 2018 at 3:08 am
Luis Cazares - Monday, March 5, 2018 6:33 AMVastSQL - Monday, March 5, 2018 5:42 AMChanged one of the existing column datatype from varchar(250) to nvarchar(250) but the column still showing arabic characters as ??How can i resolve this?
As Steve mentioned, once the data is saved or converted into varchar, there's no way to get the unicode data back.
If after the data type change, you still can't store the arabic characters correctly, you need to check your string handling. Here's an example of what I mean.
DECLARE @test-2 TABLE( MyString nvarchar(250));INSERT INTO @test-2 VALUES('طالÙٱئذش'); --Random string without any knowledge on what it means
INSERT INTO @test-2 VALUES(N'طالÙٱئذش');SELECT *
FROM @test-2;
Thanks Luis,
Data get inserted using Linq query and we tried creating a new nvarchar column inserted into both column the same value at once and the new column is populating data properly but the column we changed from varchar to nvarchar is still showing data as ??
March 6, 2018 at 7:02 am
VastSQL - Tuesday, March 6, 2018 3:08 AMThanks Luis,Data get inserted using Linq query and we tried creating a new nvarchar column inserted into both column the same value at once and the new column is populating data properly but the column we changed from varchar to nvarchar is still showing data as ??
If it's data that was already in the table before the data type change, then it's lost. You would need to correct it as there's nothing stored that would allow you to identify which were the characters that you intended to store in the first place.
March 6, 2018 at 8:44 am
VastSQL - Monday, March 5, 2018 5:42 AMChanged one of the existing column datatype from varchar(250) to nvarchar(250) but the column still showing arabic characters as ??How can i resolve this?
Once the Unicode data was converted to non Unicode data and stored in the varchar(250) column the data is lost. Converting the column to nvarchar(250) will not recover the data. You will have to go back to the original source to recover the data.
Edit: Should have read further, sorry for repeating what has already been said.
March 6, 2018 at 11:31 pm
Lynn Pettis - Tuesday, March 6, 2018 8:44 AMVastSQL - Monday, March 5, 2018 5:42 AMChanged one of the existing column datatype from varchar(250) to nvarchar(250) but the column still showing arabic characters as ??How can i resolve this?
Once the Unicode data was converted to non Unicode data and stored in the varchar(250) column the data is lost. Converting the column to nvarchar(250) will not recover the data. You will have to go back to the original source to recover the data.
Edit: Should have read further, sorry for repeating what has already been said.
Thanks Lynn
I am talking about new data being inserted after changing the data type
March 7, 2018 at 1:03 am
Look at your LINQ. Is it still mapping the column as ascii text?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
March 7, 2018 at 4:54 am
GilaMonster - Wednesday, March 7, 2018 1:03 AMLook at your LINQ. Is it still mapping the column as ascii text?
Thanks Gail.
Finally find the issue. In Db context the unicode was set to false. Developer changed it to True and now its working as expected.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply