Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What datatype to choose with SQLServer70

Status
Not open for further replies.

jhilltektips

Programmer
Jul 4, 2003
19
US
Hello,

I always use "nvarchar" as datatype in SQLServer70.
SOmetimes, I wonder if there is a difference between "nvarchar" and just "char".
What about "int" and numeric"?
Just wondering what is better for sentences as values.

Thnaks,
Jason
 
nvarchar uses the unicode character set, while varchar uses ascii. nvarchar is probably better, especially if the possibility of foreign language storage exists. It takes slightly more storage.

int is for integers, while numeric is the same as decimal, and is used for fixed-decimal numbers.
 
Thank you dmhirsch,

So, you are saying that overall, I should use "nvarchar" over just "char"?
This will allow foreign characters in my table?

Thank you,
Jason
 
What I meant was to use (usually) nvarchar over varchar. The difference between nvarchar and nchar (or varchar and char) is that nvarchar can hold a variable number of characters up to the maximum you have defined. For example, nvarchar(20) can hold anywhere from 0 to 20 characters. nchar columns hold an exact number of characters, for when you know the exact length of the text to be stored, e.g. social security numbers or state codes. If you make a nchar(20) field and store a 10 character text in it, it will fill out the other 10 characters with spaces so that it's always 20 characters.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top