Data Types and Storage

G

Greg

I've come across a few statements that conflict eachother and I'm wondering
what is correct.

I cam across a web-site (I do not remember the site right now), that
explained each data type. For the NVarChar data type it suggested that you
never store a NULL value. It said, if you have a NULL value, you should
insert some common text instead, such as "N/A or TBD", etc. It said, stored
the text "N/A" would take up a lot less space than a NULL. This doesn't make
much sense to me.

Now, I'm reading the Wrox Beginning Visual Basic 2005 Databases book. It
states if you come across a situation where you might be inserting an empty
string or a zero length string, you should be sure to convert it to a NULL
value instead to save space. Now, this make sense to me.

The only thing I'm not sure about, is whether these statements were
referring to the NVarChar or VarChar data types.

So, in the case of these two types of data types, is there every a situation
where it would be better not to have a NULL value in the field?

And, finally, regarding the differences of NVarChar and VarChar.

In regards to space requirements, the NVarChar will typcially require up to
double the storage space to store the same text as a VarChar data type? Plus,
if I understand it correctly, if my application is targeted to only be
distributed within the United States, using the VarChar type is OK, where if
I am planning on distributing my application to other countries, I should use
the NVarChar data types to accomodate International Character Sets?

Thanks,
Greg
 
A

Armin Zingler

Greg said:
Now, I'm reading the Wrox Beginning Visual Basic 2005 Databases

Even if you read it in a VB book, the issue is not specific to the
VB.Net language. If I see it right, it's solely related to the database,
so I'd ask in a database group.


Armin
 
G

Greg

Yes, you could possible be right. The web-site I found that said it would be
best to put an "N/A" in the field instead of a NULL was a SQL Server specific
site, while the Book was a VB.Net specific book that said to use NULL. If I
had to bet on the right answer, I'd go with the SQL Site.

Anyway, my aplogies for posting this in the wrong group. I will copy/paste
this into the SQL Server group instead.
 
S

Stephany Young

I don't think that Armin meant for you to believe what you read on some SQL
Server specific site rather than what you read in some VB.Net specific
book.

Rather, he meant that your questions were SQL specific therefore you should
post them in a SQL specific newsgroup.
 
A

Armin Zingler

Greg said:
Yes, you could possible be right. The web-site I found that said it
would be best to put an "N/A" in the field instead of a NULL was a
SQL Server specific site, while the Book was a VB.Net specific book
that said to use NULL. If I had to bet on the right answer, I'd go
with the SQL Site.

Anyway, my aplogies for posting this in the wrong group. I will
copy/paste this into the SQL Server group instead.

No need to apologize! I sometimes think telling people why this group is
not the (most) suitable one sounds like blaming them for having
committed a crime. :) I apologize if it did sound like that (for now
and all future cases...). No, I meant it as a hint only.


Armin
 
S

Steven Cheng[MSFT]

Hi Greg,

Yes, I agree that you may get more centric answers in some SQL Server
newsgroup.

Anyway, I'd be glad to answer your question:)

1. for the empty value, I would suggest you use the Null value(in ADO.NET
code it refer to DBNull) rather than the empty string.

2. Yes, NVarChar and Varchar differ on the underying persisting charset of
the text. NVarChar is unicode type which can hold text that may contains
mutilingual characters. While for VarChar, it is used for single
charset/language, it can hold english characters(ASCII charset) and a
certain multi-byte charset(by specify a collation for your database or
table).

Hope this helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

----------------------------
From: =?Utf-8?B?R3JlZw==?= <[email protected]>
References: <[email protected]>
 
C

Cor Ligthert[MVP]

Greg,

Buy another book, this seems to me written by somebody who does not know the
rights of the case.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top