Solved

SQL query to decode a value returned from function

Posted on 2008-06-18
3
714 Views
Last Modified: 2010-04-21
I have a stored procedure which has a few parameters.
One of the parameters is @Check

I need to decode a value returned from a function
fn_CheckValid which takes in a string of an order no and returns 0 or 1

what I need to do is if the value returned is 0 - interpret as false if 1 interpret as true
and then check this with @Check parameter. @Check can have only two vlaue true or false

So I need somehow to convert the value returned from the function to true or false and then check if it matches the parameter @Check

This is what I have now, but is incorrect since the value returned from function is fn_CheckValid is only 1 or 0 and the @check is only true or false.

fn_CheckValid(strOrder) = @Check
0
Comment
Question by:countrymeister
[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 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 200 total points
ID: 21816051
what data type is @check ? assuming that it is "bit" data type, that code will do.
0
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 50 total points
ID: 21816054
if (select case when dbo.fn_CheckValid(strOrder)  = 1 THEN 'True' Else 'False' end )  = @Check
0
 
LVL 1

Author Closing Comment

by:countrymeister
ID: 31468528
Angel, I had @Check as string, I made that a bit and it worked.

Aneesh , your solution worked too, but I was looking for minimal change on the code I had
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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 shrink a transaction log file down to a reasonable size.

695 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