Need advice to design table

  • I intent to store value year and month in table. Currently, my table as follow

    declare @tSample table

    (

    rYear varchar(4),

    rMonth varchar(2)

    )

    insert into @tSample values('2009','11')

    insert into @tSample values('2009','12')

    insert into @tSample values('2010','01')

    My question is, is that my table design is accurate?

  • Firstly, why are you storing two numbers in varchar columns? Second, why are you storing a date split into two columns? What's wrong with a datetime column with a constraint ensuring that only the 1st day of the month can be inserted?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • You might think about using a calendar table.

    Search this site for details.

    An example can be found for instance here .

    You could also have a look at the link in my signature regarding usage of a Tally table. There's an example on how to populate a calendar table in there, too.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

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

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