i have the foll id's (sample 2005053110073148) generated by a function. I
need to store the data in a table. What is
the best datatype should i give to the column to enhance performance and
storage.
ThanksIt looks like the return data is of a "datetime" datatype. (Close but not
exact.)
If you can use the "datetime" datatype, use it. if not, use Char(16). This
assumes the result is always 16 bytes. Stay away from "varchar" here if the
results are always a fixed length.
"Chris" wrote:
> i have the foll id's (sample 2005053110073148) generated by a function. I
> need to store the data in a table. What is
> the best datatype should i give to the column to enhance performance and
> storage.
> Thanks|||Chris wrote:
> i have the foll id's (sample 2005053110073148) generated by a
> function. I need to store the data in a table. What is
> the best datatype should i give to the column to enhance performance
> and storage.
> Thanks
CHAR or DECIMAL. A CHAR would require 16 bytes of storage. A DECIMAL
would require 9 bytes of storage. Can you provide more detail about what
this number is.
-
David Gugick
Quest Software
www.imceda.com
www.quest.com|||It depends on whether this id has any meaning, what
the possible values of this id are, and how it will be
used in the bigger picture. Few if any questions
about database design that can be answered without any
context, and this is not one of them.
If you need to interpret all or part of it as a date/time, store that
part as a datetime (or smalldatetime if one-minute precision
is enough). If this is "just an identifier" and you will never
need to interpret anything except perhaps the ordering,
decimal(16,0) may be a good choice (or decimal(bigger#,0),
if these can be longer). If some of the positions can contain
characters other thhan 0-9, you'll need a character type.
Steve Kass
Drew University
Chris wrote:
>i have the foll id's (sample 2005053110073148) generated by a function. I
>need to store the data in a table. What is
>the best datatype should i give to the column to enhance performance and
>storage.
>Thanks
>|||Hi,
Sorry about the details. The (2005053110073148) is just an identifier. I
won't need to interpret anything. It's just there to identify a group of
record. I have a function that takes the datetime and then concatenate a
randum number at the end. It's being returned from the function as a string
so the parameter in my sp is accepting it in a output variable as
declare @.id nchar(17)
Thanks
"Chris" wrote:
> i have the foll id's (sample 2005053110073148) generated by a function. I
> need to store the data in a table. What is
> the best datatype should i give to the column to enhance performance and
> storage.
> Thanks|||I used nchar(17) because I see in BOL nchar is 4000. Is that a good choice?
"Chris" wrote:
> i have the foll id's (sample 2005053110073148) generated by a function. I
> need to store the data in a table. What is
> the best datatype should i give to the column to enhance performance and
> storage.
> Thanks|||If it's all digits, and there are never any leading zeros,
nchar(17) is a bad choice. It takes 34 bytes per value,
which is about 4 times as much storage as you probably
need. If 17 digits is the maximum possible length (this one
is 16 digits) and it will always be a string of digits with no
leading zero, decimal(17,0) is a better choice. Or you could
use bigint, which would save one more byte per value.
SK
Chris wrote:
>I used nchar(17) because I see in BOL nchar is 4000. Is that a good choice?
>"Chris" wrote:
>
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment