Should I have a date column when one of the other colums contain a date

  • I need to save a serial number.

    The serial number consist of a date and a sequential number, e. g. ddmmyy######, 111214000001.

    Is it a good idea to also have a date field where I save the same date that is in the serial number?

    I will create about 50000 records a day and it should be saved for at least a year.

    The database will be used to find a specific serial number and "show" all serial numbers for that day.

    // Anders

  • Yes. You're going to want to have that date value as a date. Otherwise, you'll have to parse that string and it will prevent index and statistics use leading to very poor performance.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • You will need to have a date field if you are going to query by date. Well, do it easily anyway. You could write a query to pull the date back out of the serial number then convert it back into a date but what a pain. If there is no overwhelming reason not to add the date field, I'd just add it.

  • Thanks for the answers (or maybe the confirmations). I guessed that it would be a good thing!

    // Anders

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

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