Solved

SQL Server populating a drop-down result set with Null

Posted on 2014-09-18
5
111 Views
Last Modified: 2014-10-05
I have a drop down populated with a values from a table lets call SalesContacts.  Currently if someone selects any one of these contacts I take the selected value, set it to variable and essentially do a lookup/filter to display only the data of the selection.

My problem is if someone wants to clear the data they can not clear the data since I have no value called Null in the set of values.  How do I populate an additional value called Null for the universe of values ?
0
Comment
Question by:upobDaPlaya
  • 3
5 Comments
 
LVL 25

Assisted Solution

by:Shaun Kline
Shaun Kline earned 250 total points
Comment Utility
You could insert a new entry at the top of your list with a value (let's say -1) and text (maybe "(All)"). When this item is selected, your code / query would handle this specific value to "remove" the existing filter from the your query.
0
 
LVL 65

Accepted Solution

by:
Jim Horn earned 250 total points
Comment Utility
Give something like this a whirl, then when yu display it on your report only show the id and name columns:

SELECT NULL as id, '< ALL >' as name, 1 as sort_order
UNION ALL
SELECT id, name, 2 as sort_order
FROM SalesContacts
ORDER BY name, sort_order
0
 

Author Comment

by:upobDaPlaya
Comment Utility
Hi Jim,

It says invalid column name 'ID' ?  Is this the Unique ID of the table
0
 

Author Comment

by:upobDaPlaya
Comment Utility
Disregard..I got it..sorry
0
 

Author Closing Comment

by:upobDaPlaya
Comment Utility
Thanks..for the suggestions
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now