Solved

SQL Server populating a drop-down result set with Null

Posted on 2014-09-18
5
117 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 66

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

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

707 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