?
Solved

SQL Server populating a drop-down result set with Null

Posted on 2014-09-18
5
Medium Priority
?
121 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 1000 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 1000 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

762 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