Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Char VS Varchar

Author  Topic 

Lopaka
Starting Member

48 Posts

Posted - 2007-06-07 : 13:22:55
I am designing a new Database and in setting up the tables the following questions came to me:
1. Char VS Varchar: When exactly would you use Char if Char uses a fixed length and Varchar is variable length. Since most of the time you would NOT fill a character string you would use less bytes over time?
2. Character Strings VS Unicode Character Strings: Again, when would you use unicode over character?

Thank you


Robert R. Barnes

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-06-07 : 13:26:31
1. If your data almost always will fill the column, then use char. One example of a char column would be the state abbreviations.
2. If you need to store unicode data, then you need to use unicode data types. This is done when you need to support languages that use unicode data type.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

Lopaka
Starting Member

48 Posts

Posted - 2007-06-07 : 13:36:14
I understand response 1, but 2? If Unicode then I am able to store French, Italian, Spanish, etc... Unicode supports the special charactors and the other does not?

Robert R. Barnes
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-06-07 : 14:03:31
Please check SQL Server Books Online for details on unicode data.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

TonyTheDBA
Posting Yak Master

121 Posts

Posted - 2007-06-08 : 08:59:10
quote:
Originally posted by Lopaka

I understand response 1, but 2? If Unicode then I am able to store French, Italian, Spanish, etc... Unicode supports the special charactors and the other does not?

Not so much Spanish, French etc as the characters for these are included pretty much in the extended Ascii Set And code pages., its when you need to store Korean, Arabic, Japanese characters when the Double byte Characterset is used . . . Hence using unicode . . . . Using unicode data types occupies twice the space the standard type would use.

This is an argument I have with one of my developers on numerous occasions, usually accompanied by the comment "Have you had an extra bowl of stupid this morning" :)

--
Regards
Tony The DBA
Go to Top of Page
   

- Advertisement -