Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

varchar versus nvarchar Expand / Collapse
Author
Message
Posted Thursday, December 4, 2008 10:08 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 4:08 PM
Points: 40,177, Visits: 36,580
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 2008, MVP
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

Post #613890
Posted Thursday, December 4, 2008 10:18 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 7:50 AM
Points: 1,186, Visits: 1,977
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.
Post #613902
Posted Thursday, December 4, 2008 10:23 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Wednesday, October 8, 2014 4:15 AM
Points: 20,581, Visits: 9,619
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!!!
Post #613906
Posted Thursday, December 4, 2008 10:33 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, May 30, 2014 6:27 PM
Points: 2,808, Visits: 7,175
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.
Post #613914
Posted Thursday, December 4, 2008 10:34 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 7:50 AM
Points: 1,186, Visits: 1,977
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.
Post #613916
Posted Friday, January 28, 2011 4:46 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 11:12 AM
Points: 7,791, Visits: 9,545
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.


Tom
Post #1055684
Posted Tuesday, February 1, 2011 8:48 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Thursday, March 6, 2014 7:07 AM
Points: 660, Visits: 639
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!

Post #1056874
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse