Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2012-07-27 : 11:18:01
|
Hi friends,I have this following oracle query...select *from customer WHERE LNNVL (cust_ID != :v_cust_id)AND LNNVL (customer_name != :v_customer_name)Can someone help me get this query in Sql server please...The scneario for this cquery is to retrieve data from my Customer tableby providing parameters CUST_ID and Customer_Name What i basically want is the where condition should hold true when null is passed for any of the parameterIf custid is passed and customer_name is null then return records forall those cust_id and vice versaWhen parameter values are passed for both , then the records should be returned for that custid 'and' taht customer_name ...Please guide me thanks.. |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-07-27 : 11:37:45
|
I believe this is close. There might be some differences in how the LNNVL fuction handles NULL values that I not fully aware of.select *from customer WHERE (cust_ID = @v_cust_id OR @v_cust_id IS NULL)AND (customer_name = @v_customer_name OR @v_customer_name IS NULL) |
 |
|
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2012-07-27 : 11:55:37
|
Thank You Lamprey...it works just fine... |
 |
|
|
|
|