which data type can save bangla Language in sql server? - sql

I want to save bangla Language in sql server. Using which data type I can Do it in sql server 2005 or sql server 2008.
I tried varchar and varbinary type but it cannot save bangla Language.
How is it possible?

You're using SQL_Latin1_General_CP1_CI_AS for your collation, which is suited for the Latin character set (ISO-8859-1). To store characters fromother character sets, you can use the NVARCHAR() which can store the full Unicode range, irrespective of collation - this does mean it will need to be treated as NVARCHAR() all the way, as quoted constants (e.g. N'বাংলা Bangla'), as the data types for parameters to stored procedures, etc.

Related

Handling chinese characters in SQL Server 2016

Our ETL team is sending us some data with chinese description. When we are loading that data in our SQL Server database, those descriptions are coming up as blank.
We tried changing the column format to nvarchar, but that doesnt help.
Can you please help.
Thanks
You must use the N prefix when dealing with NVARCHAR.
INSERT INTO table (column) VALUES (N'chinese characters')
Prefix a Unicode character string constants with the letter N to
signal UCS-2 or UTF-16 input, depending on whether an SC collation is
used or not. Without the N prefix, the string is converted to the
default code page of the database that may not recognize certain
characters. Starting with SQL Server 2019 preview, when a UTF-8
enabled collation is used, the default code page is capable of storing
UNICODE UTF-8 character set.
Source: https://learn.microsoft.com/en-us/sql/t-sql/data-types/nchar-and-nvarchar-transact-sql?view=sql-server-2017

Error in collate SQL_Latin1_General_CP850_BIN2 with UTF-8 SQL Server

I'm trying to select a column from my database that has SAP's informations.
But when I execute my select all my special characters as 'À Ê' are broken, for example:
TELECOMUNICAÃiES (INCLUI ASSIST-NCIA T+CNICA)
should be
TELECOMUNICAÇÕES (INCLUI ASSISTÊNCIA TÉCNICA)
Is there some way to resolve this using a cast or a convert functions?
OBS: All my tables are configured with SQL_Latin1_General_CP850_BIN2 as required of SAP, but the columns are varchar instead of nvarchar
Probably the data is corrupted because this collation is default in any Windows

Read SQL Server field text value in Delphi XE with simultaneously character conversion

I have a SQL Server 2005 database with COLLATION SQL_Latin_General_CP1_CI_AS and I want to run a query from Delphi XE via ADO. Data in SQL Server is Greek and Latin characters. But in Delphi I get unreadable character strings. How can I manage this problem with Delphi XE ?
Since you say that you have both Greek and Latin characters in the db I guess that you are already using nvarchar in the db.
In Delphi you should then use TWideStringField for nvarchar fields. TStringField is for varchar (ansistring).
Field1 contains "γειά σου"
StringField := ADODataSet1.FieldByName('Field1') as TStringField;
ShowMessage(StringField.Value);
ShowMessage shows "?e??s??"
This works fine
WideStringField := ADODataSet1.FieldByName('Field1') as TWideStringField;
ShowMessage(WideStringField.Value);
Edit 1
If you have varchar fields in db you should use TStringField and you need to make sure that the "Language for non-Unicode programs" is Greek(Greece).
"Control Panel - Region and Language - Administrative - Change system locale..."
I have found that sometimes UTF-8 is stored in databases in VarChar fields, usually from Java programs.
If you see things like â€", there's a good chance that's what is going on.
You could try
// Delphi 2009+
UTF8ToUnicodeString(RawByteString( db_value ))
// Delphi 2007 and older
UTF8Decode( db_value )
If this is the case, you can also use a sql function to convert the VarChar fields to NVarChar

Japanese character are saved as question mark in SQL Server

I'm working on SQL Server 2005, in which I have a database. When I use Japanese Characters in my application, they are stored as question marks in the databse. I would like to which Collations should I use save the japanese characters properly.
Note: Additional info(if it helps) In MySQL, we have used UTF8 as default character set in the startup variable and it works file.
Thank you,
Pavan
Japanese_90 appears to be the new collation name.
http://msdn.microsoft.com/en-us/library/bb330962%28v=sql.90%29.aspx#intlftrql2005_topic24
Note, you might want to consider the _KS suffix if you want to consider Hirigana/Katakana whilst sorting.
Like Marc_S says, you will also want to ensure your column datatype is nvarchar

SQL Server database with Latin1 codepage shows Japanese Chars as "?"

Three questions with the following scenario:
SQL Server 2005 production db with a Latin1 codepage and showing "?" for invalid chars in Management Studio.
SomeCompanyApp client as a service that populates the data from servers and workstations.
SomeCompanyApp management console that shows "?" for Asian characters.
Since this is a prod db I will not write to it.
I don't know if the client app that is storing the data in the database is actually storing it correctly as Unicode and it simply doesn't show because they are using Latin1 for the console.
Q1: As I understand it, SQL Server stores nvarchar text as Unicode regardless of the codepage or am I completely wrong and if the codepage is Latin1 then everything that is not in that codepage gets converted to "?".
Q2: Is it the same with a text column?
Q3: Is there a way using SQL Server Management Studio or Visual Studio and some code (don't care which language :)) to query the db and show me if the chars really do show up as Japanese, Chinese, Korean, etc.?
My final goal is to extract data from the db and store it in another db using UTF-8 to show Japanese and other Asian chars as what they are in my own client webapp. I will settle for an answer to Q3. I can code in several languages and at the very least understand some others but I'm just not knowledgeable enough about Unicode. In case you want to know my webapp will be using pyodbc and cassandra but for these questions that doesn't matter.
When inserting into an NVARCHAR column in SSMS, you need to make absolutely sure you're prefixing your string with a N:
This will NOT work:
INSERT INTO dbo.MyTable(NVarcharColumn) VALUES('Some Text with Special Char')
SQL Server will interpret your string in the VALUES(..) as VARCHAR and thus strip off any special characters.
You need this:
INSERT INTO dbo.MyTable(NVarcharColumn) VALUES(N'Some Text with Special Char')
Prefixing your text literal with an N'..' tells SQL Server to treat this as NVARCHAR all the way.
Does this help you solve your Q3 ??