Solved

SQL Server populating a drop-down result set with Null

Posted on 2014-09-18
5
113 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 26

Assisted Solution

by:Shaun Kline
Shaun Kline earned 250 total points
ID: 40331118
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
ID: 40331121
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
ID: 40331548
Hi Jim,

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

Author Comment

by:upobDaPlaya
ID: 40331554
Disregard..I got it..sorry
0
 

Author Closing Comment

by:upobDaPlaya
ID: 40362954
Thanks..for the suggestions
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

863 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

21 Experts available now in Live!

Get 1:1 Help Now