I am using Castle ActiveRecord as my ORM. When I try to store unicode strings, I get question marks instead.
Saving unicode strings worked perfectly when I was using mysql, but when I recently switch to SQL Server it broke. How should I go about fixing this?
You're most likely using the incorrect SQL Server data type. varchar is meant for a plain-old character while nvarchar is meant for Unicode characters. The same applies for char & nchar and text and ntext.
MSDN for SQL Server data type
MSDN for SQL Server Unicode data
Related
Rupee symbol '₹' and Nigeria naira '₦' are not supported by database. It is saving as '¿' in the database Oracle and SQL Server.
Even I set as NLS_CHARACTERSET=WE8MSWIN1252 in Oracle, it's not working
Any other settings has to be done in db?
For SQL Server, you must:
define the column to hold this information as NVARCHAR(n) datatype (not varchar(n) !)
use the N'...' syntax when inserting values from SQL script to ensure Unicode storage
INSERT INTO dbo.YourTable(UnicodeColumn)
VALUES(N'₹'), (N'₦')
use the correct Unicode data type for e.g. a parameter if you're inserting your values from frontend code (e.g. PHP, C#, Java)
I need to upload some data from an Oracle table to a SQL Server table. The data will be uploaded to the SQL server using a Java processing utilising JDBC facilities.
Is there any benefit in creating the SQL server columns using nvarchar instead of varchar?
Google suggests that nvarchar is used when UNICODE characters are involved but i am wondering does nvarchar provide any benefit in this situation? (i.e. when the source data of the SQL Server table comes from an Oracle database running a Unix environment?)
Thanks in advance
As you have found out, nvarchar stores unicode characters - the same as nvarchar2 within Oracle. It comes down to whether your source data is unicode - or whether you anticipate having to store unicode values in future (e.g. internationalized software)
I am using Access 2003 as a front end UI for a SQL Server 2008 database. In looking at my SQL Server database design I am wondering if nvarchar was the right choice to use over varchar. I chose nvarchar because I thought it would be useful in case any characters represented by unicode needed to be entered. However, I didn't think about any possible issues with Access 2003 using the uni-code datatype. Are there any issues with Access 2003 working with unicode datatypes within SQL Server (i.e. nvarchar)? Thank you.
You can go ahead and use nvarchar, if that's the correct datatype for the job. Access supports Unicode data, both with it's own tables and with external (linked) tables and direct queries.
I am migrating data from a Oracle on VMS that accesses data on SQL Server using heterogeneous services (over ODBC) to Oracle on AIX accessing the SQL Server via Oracle Gateways (dg4msql). The Oracle VMS database used the WE8ISO8859P1 character set. The AIX database uses WE8MSWIN1252. The SQL Server database uses "Latin1-General, case-insensitive, accent-sensitive, kanatype-insensitive, width-insensitive for Unicode Data, SQL Server Sort Order 52 on Code Page 1252 for non-Unicode Data" according to sp_helpsort. The SQL Server databases uses nchar/nvarchar or all string columns.
In Application Express, extra characters are appearing in some cases, for example 123 shows up as %001%002%003. In sqlplus, things look ok but if I use Oracle functions like initcap, I see what appear as spaces between each letter of a string when I query the sql server database (using a database link). This did not occur under the old configuration.
I'm assuming the issue is that an nchar has extra bytes in it and the character set in Oracle can't convert it. It appears that the ODBC solution didn't support nchars so must have just cast them back to char and they showed up ok. I only need to view the sql server data so I'm open to any solution such as casting, but I haven't found anything that works.
Any ideas on how to deal with this? Should I be using a different character set in Oracle and if so, does that apply to all schemas since I only care about one of them.
Update: I think I can simplify this question. SQL Server table uses nchar. select dump(column) from table returns Typ=1 Len=6: 0,67,0,79,0,88 when the value is 'COX' whether I select from a remote link to sql server, cast the literal 'COX' to an nvarchar, or copy into an Oracle table as an nvarchar. But when I select the column itself it appears with extra spaces only when selecting from the remote sql server link. I can't understand why dump would return the same thing but not using dump would show different values. Any help is appreciated.
There is an incompatibility between Oracle Gateways and nchar on that particular version of SQL Server. The solution was to create views on the SQL Server side casting the nchars to varchars. Then I could select from the views via gateways and it handled the character sets correctly.
You might be interested in the Oracle NLS Lang FAQ
I have a client database with English and French data in windows-1252 encoding. I need to fetch this data as part of an AJAX call and send it in UTF-8 format.
Is there a way I can pass the data through a stored proc to perform this conversion?
My web app cannot be altered to perform this conversion itself.
Microsoft has published a UTF-8 CLR UDT for SQL Server 2008 that can be installed on SQL Server 2005. See here: msdn.microsoft.com/en-us/library/ms160893.aspx .
try to cast as nvarchar
or even better use nvarchar columns