April 22, 2009 at 11:01 am
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?
April 22, 2009 at 11:03 am
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
April 23, 2009 at 6:16 am
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
April 28, 2009 at 3:44 pm
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