About Lookup Table

  • hi,

    I have different lookup tables in my DB (used to fill different dropdownlist). Almost all of them has a ID and a DESCRIPTION column.

    Some of them are required field when the user insert data.

    I thought to insert in each of them a record with ID=0 and DESCRIPTION="*** NOT SELECTED ***".

    In this way i have a common default value for the dropdownlist (insted of programmatically insert it) and, even the non required field are set (with the default value).

    What do think about?

  • That's pretty usual. Lots of applications do something like that.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Yeah, a pretty standard solution for avoiding NULL values.

    "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 can also populate the drop-downs using a UNION query if you don't want to add a default to the actual code table.

    SELECT

    0 AS ID

    , '*** None Selected ***' AS Descr

    UNION ALL

    SELECT ID, Descr

    FROM YourCodeTable

    Todd Fifield

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

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