1 column vs 2 columns (using integer and varchar)

  • hi

    i need to store a value that can be integer or string (depends on a key value)

    is it better to use 2 columns or to use 1 column (varchar) and store all numbers as a varchar?

    thanks for help

    michael

  • In terms of size and space usage you'd be better off with a single character column.

    How big are these values going to be? Are they going to used in joins or for searching?

  • michel.zdw (11/26/2010)


    hi

    i need to store a value that can be integer or string (depends on a key value)

    is it better to use 2 columns or to use 1 column (varchar) and store all numbers as a varchar?

    thanks for help

    michael

    Can you provide a little more explanation - why would it sometimes be an integer, why other times it could be a string?


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • its the value in a key <-> value table and some values can be numbers or text

    i think the numbers will be between 0 and 1000 but this can change in future. even then they should not exceed 8 digits

    varchars are designed up to 100 chars, in fact they will be smaller than 30 chars mostly

    these values are not supposed to be in where clauses and there will be no index on it

  • An entity-attribute-value system?

    Your original post asked how best to store a value which could be either an integer or a character value in one or more columns of a table.

    What about the identity (descriptive name) of the integer/character value? Where will that be held?


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply