473,396 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Evaluate 1 or NULL or Both in Stored Procedure

Hello,
I have a field in a table that is either 1 or NULL. I have a stored procedure that evaluates this condition. I also have an SSRS (2008) report that passes a parameter to this stored procedure.

If a user selects yes (passes 1) OR no (passes NULL), the following statement works correctly:

Select *
from foo
where ISNULL(c1, 0) = ISNULL(@c1,0)

However, I want the user to be able to select Yes, No, or BOTH, but I cannot figure out how to have the c1 field be either 1 or NULL to return ALL records. Any help would be greatly appreciated.
May 13 '13 #1
2 1254
Rabbit
12,516 Expert Mod 8TB
Use an OR to check for your BOTH value, whatever that is that you assigned to it.
May 14 '13 #2
ck9663
2,878 Expert 2GB
What do you mean by "both" ? A column can only hold a single value. It's either 1 or NULL.

But if you mean that if a user wants to return everything regardless of it's value, you might need a conditional where clause.

Good Luck!!!


~~ CK
May 14 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Andrei | last post by:
Hi everyone, I am a complete noob with stored procedures. I was asked to modify the following stored procedure so that it includes the following conditions: IF InvWarehouse.DateLastSale is...
1
by: Icarus | last post by:
Is it possible to have to ORDER BY statements in the same stored procedure? I am trying to use the same stored procedure for two different pages but the data returned needs to sorted DESC on one...
4
by: stjulian | last post by:
I have a stored procedure that is supposed to 1. Increment a counter in Table A via a transaction 2. Use this value as the primary key to add in an address to customers Table B (Referenced as a...
3
by: Gaz | last post by:
I have a table which has 10 columns which make up the secondary key. 1 or more of these columns can be set but the remaining columns in the secondary key will be null. For example : id k1 k2...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
3
by: Pieter | last post by:
Hi, I have a View which contains (of course) several columns. Now I want to make a Stored Procedure that does a Select based on the parameters. For exemple: One time I want to select all the...
1
by: deepdata | last post by:
Hi, I am trying to fetch data from db2 (express version) database by calling stored procedure. I have tried to use both cursor and for loop but still i am getting error. --======Start...
4
by: Pakna | last post by:
Hi, is there any way to call a JAVA stored procedure from a SQL Trigger? We are having difficulties with this and cannot verify whether DB2 even *has* this capability? Thank you very much....
2
by: rn5a | last post by:
How do I pass a NULL value to a field while inserting records in a SQL Server 2005 DB table using a stored procedure? I tried the following but it inserts an empty string & not a NULL value: ...
9
by: Jonathan Wood | last post by:
I've written a stored procedure and would like to filter the results returned based on the argument. It works so far, but I'd also like to allow this argument to be null. I know I can rewrite my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.