December 1, 2009 at 4:08 am
Hi guys,
I have a site which is starting to use other languages such as Chinese. We have had a slight problem with Chinese characters being stored as "?" in the DB but this was fixed by placing N in front of the text on the SQL inserts/updates
i.e. set myField = N'家'
All my relevant text fields are nvarchars in the DB.
My question is this:
I have a single script which builds the SQL statements based on the form details passed to it so my update placing the 'N' before all text fields is across the whole site. Are there any consequences to this for non-unicode chars or will it be ok? Storage space issues? Field length issues I should worry about?
I just wanna make sure I'm covering all bases here 🙂
Cheers in advance for your help.
December 1, 2009 at 7:04 am
All the N does is specify that the string you are passing is unicode. If the columns in your database are already defined as NCHAR/NVARCHAR then you shouldn't have any issues with storage, field length, or non-unicode characters as SQL Server has already been doing an implicit conversion to unicode for those characters.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
December 1, 2009 at 7:06 am
Hi Jack,
Ok. That's great. It should be all ok then. Just need to check all my fields are definitely nvarchars and i'll make the update.
December 1, 2009 at 7:20 am
Simon G (12/1/2009)
Hi Jack,Ok. That's great. It should be all ok then. Just need to check all my fields are definitely nvarchars and i'll make the update.
The Chinese alphabet is more than 2500 characters compared to the 26 characters Latin alphabet so you need to add the collation of the version of Chinese you are accepting in the column definition in your database. You also need collation precedence check it out in the BOL or MSDN.
Kind regards,
Gift Peddie
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply