Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


varchar versus nvarchar


varchar versus nvarchar

Author
Message
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47388 Visits: 44399
declare @test VARCHAR(20)
SET @test = 'resumé'
select @test



There's a difference between extended ASCII and unicode.


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

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Mauve
Mauve
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1246 Visits: 2049
GilaMonster (12/4/2008)[hr
There's a difference between extended ASCII and unicode.

True, but the support of extended (8-bit) ASCII is also governed by the collation of the database and the calling application, among other things.

Best bet is to to be global and use Unicode. If the application is .Net, it is a no-brainer as .Net is Unicode.


(PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.
Ninja's_RGR'us
Ninja's_RGR'us
SSC-Insane
SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)

Group: General Forum Members
Points: 20941 Visits: 9671
JohnG (12/4/2008)
Note that even in America, extended ASCII is very common. Just think of all of peoples names that have accents in them. Or the word resumé. Let alone, there is this province in Canada that has French as the standard language.

So if you are designing a new system, use NCHAR and NVARCHAR. Trust me and you'll thank me later.


I'm from Quebec... and varchar is more than enough to cover all our words!!!
steveb.
steveb.
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2856 Visits: 7195
Ninja's_RGR'us (12/4/2008)
JohnG (12/4/2008)
Note that even in America, extended ASCII is very common. Just think of all of peoples names that have accents in them. Or the word resumé. Let alone, there is this province in Canada that has French as the standard language.

So if you are designing a new system, use NCHAR and NVARCHAR. Trust me and you'll thank me later.


I'm from Quebec... and varchar is more than enough to cover all our words!!!


Varchar will handle any Latin/Romance language easily so I can't see any French words causing an issue, but you must have names of people/business that are from different aplhabets.
Mauve
Mauve
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1246 Visits: 2049
I'll qualify my responses as follows:

If you are designing and building a system that will be used within a single language culture then by all means choose the proper database collation and use VARCHAR. If, however, your system will be used by different cultures, then you should use NVARCHAR (Unicode).

If your system is a web-application (e.g., a SaaS offering) it should be Unicode. Also note that a lot of companies are global. Those that are not, may be in the future. If not from expansion they could be as a result of a merger or acquisition (M&A).

My company has a SaaS offering that is used globally. Some of the customers are multi-lingual -- i.e., they have global offices. Consequently, the data placed into the system is from all languages and character sets.

BOL links supporting the above:
http://technet.microsoft.com/en-us/library/ms187828(SQL.90).aspx Note the reference to (North America) Mexico, Quebec, Canada and US.
http://technet.microsoft.com/en-us/library/ms188325(SQL.90).aspx

Edit: Added BOL links


(PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.
TomThomson
TomThomson
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10765 Visits: 12019
Carla Wilson-484785 (12/2/2008)
AND not too long ago, there was a forum post about trailing blanks in nvarchar, and how that can be a problem in comparisons, etc. unless you use RTRIM().

Belated response:
If the ANSI_PADDING option is set ON varchar has exactly the same trailing blanks issues as nvarchar; and the ability to set it OFF will be removed from SQL Server very soon (MS advice has for years been to keep it on at all times; setting it OFF creates big problems for indexed views and for table indexes involving computed columns, amongst other little problems) so those trailing blank issues should not be a factor in deciding between nvarchar and varchar - if you use varchar to avoid the trailing blanks issue your code will stop working in a new SQL Server release sometime soon.

BTW, what on earth is this topic doing in the relational theory forum? I don't see the connection. Unsure

Tom

Pouliot Philippe
Pouliot Philippe
Say Hey Kid
Say Hey Kid (674 reputation)Say Hey Kid (674 reputation)Say Hey Kid (674 reputation)Say Hey Kid (674 reputation)Say Hey Kid (674 reputation)Say Hey Kid (674 reputation)Say Hey Kid (674 reputation)Say Hey Kid (674 reputation)

Group: General Forum Members
Points: 674 Visits: 657
Ninja's_RGR'us (12/4/2008)
JohnG (12/4/2008)
Note that even in America, extended ASCII is very common. Just think of all of peoples names that have accents in them. Or the word resumé. Let alone, there is this province in Canada that has French as the standard language.

So if you are designing a new system, use NCHAR and NVARCHAR. Trust me and you'll thank me later.


I'm from Quebec... and varchar is more than enough to cover all our words!!!



Same. Quebec Power!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search