number as string in database

M

mp

I have a comma delim string to put in a db
each entry (comma delim) is one field
some entries represent numbers
but since they start as strings,

is it just as well to store everything as NCHAR(x) ?
(where x is largest expected item)
and let app convert to number if and when nec?

or is it better to define fields as INTEGER (or whichever type)
and cast string to numeric type on input into db?

thanks
mark
 
M

mp

Peter Duniho said:
Are the data ever actually used as integers? If so, then IMHO you should
store integers, and only use integers internally in your program. Use
strings only for data import and export. If the data are always used as
strings, then store strings.

That said, since your question pertains strictly to the database itself
and not C# at all, it's best to post it to a forum where those kinds of
questions are on-topic.

You may or may not get an answer here, and it may or may not be useful if
you do, but regardless you'll always get broader, more-specific and useful
help from a topic-specific forum.

Pete

good point,
i've gotten so used to using this grp i didn't think about it being ot.
my apologies.
mark
 
M

mp

Peter Duniho said:
[...]
i've gotten so used to using this grp i didn't think about it being ot.
my apologies.

I don't think it's so much a matter of offense as it is a matter of
seeking the best help possible for a given task.

If you're happy with a half-assed answer like I gave, then maybe you're
posting in the right newsgroup after all. :)

Pete

LOL
your half- assed answers are so far above me
i only half-assed understand them anyway :)
they're way more than satisfactory...
still i should have thought about the ot netiquette(sp?) first
....not that the ngs are so busy these days that bandwidth is a huge problem.
<g>
mark
 
A

Arne Vajhøj

I have a comma delim string to put in a db
each entry (comma delim) is one field
some entries represent numbers
but since they start as strings,

is it just as well to store everything as NCHAR(x) ?
(where x is largest expected item)
and let app convert to number if and when nec?

or is it better to define fields as INTEGER (or whichever type)
and cast string to numeric type on input into db?

Go after behavior:

"1" + "2" = "12" and "10" < "2" then go for VARCHAR(x) - I assume
it is variable length and I do not see any reason for Unicode support.

1 + 2 = 3 and 10 > 2 then go for INTEGER.

If it does not matter then go for INTEGER as it is the
most strict data type (you get some check of content
for free).

Arne
 

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