June 20, 2012 at 11:54 pm
Hi guys!
This is my sample query with catch all query logic
Declare @portfolioId Varchar(8000),
@ParentWorkids Varchar(50)
Set @portfolioId = '1800m380000iot22g3t0000000_1800m380000io7c5nr50000000'
set @ParentWorkids = '1801a2g0000ih0vl2abg000000'
Select * from Mytable1 join My table2 On
(vp.shared_portfolio_id = @portfolioId Or @portfolioId Is nuLL)
And
(vh.parent_work_id = @ParentWorkids Or @ParentWorkids Is Null)
The Solution should be lik this
Without any declaration Either one Id can be Null.
Multiple Ids can be passed in Where Condition
Select * from Mytable1 join My table2 On
(vp.shared_portfolio_id In ('1800m380000iot22g3t0000000','1800m380000io7c5nr50000000') Or @portfolioId Is nuLL)
And
(vh.parent_work_id = '1801a2g0000ih0vl2abg000000'Or @ParentWorkids Is Null)
How to handle this....
June 21, 2012 at 3:50 am
Please post the DDL, sample data along with the expected output
If you are not clear on how to do this, refer the link in my signature
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
June 21, 2012 at 3:55 am
Check out Gail Shaw's blog post, she answers your question there --> http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/%5B/url%5D
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply