> On Jul 31, 10:04 am, deepthi.duvv...@gmail.com wrote:
>
[quoted text clipped - 31 lines]
>
> - Show quoted text -
The logic is like ...
If (@var = 0 or @var = 1)
begin
;with myCTE (a,b,c) as
(select * from a inner join b on a.col = b.col
left join c on a.col = c.col
where a.col1 in (@INPar1,INPar2) and
b.Col2 between isnull(@Date1,Datecol) and isnull(@Date2,Datecol))
select * from D inner join E
where col in (select * from myCTE)
end
else if (@var = 2)
begin
;with myCTE (a,b,c) as
(select * from a inner join b on a.col = b.col
where a.col1 = @INPar1)
select * from D inner join E
where col in (select * from myCTE)
end
I also can try using two stored procedures as per Alex's suggestion,
but want to know if the above logic is valid at all or not.
Thanks all.
Hugo Kornelis - 31 Jul 2008 18:04 GMT
>I also can try using two stored procedures as per Alex's suggestion,
>but want to know if the above logic is valid at all or not.
Hi deepthi.duvvuru,
The logic is valid. (Though I prefer having the semicolon at the end of
each statement instead of right in front of some statements that happen
to need it)
What problems were you having with the code? The only problem I see in
your code is using a JOIN but no ON condition.

Signature
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
deepthi.duvvuru@gmail.com - 31 Jul 2008 18:13 GMT
On Jul 31, 1:04 pm, Hugo Kornelis
<h...@perFact.REMOVETHIS.info.INVALID> wrote:
> On Thu, 31 Jul 2008 09:38:54 -0700 (PDT), deepthi.duvv...@gmail.com
> wrote:
[quoted text clipped - 14 lines]
> Hugo Kornelis, SQL Server MVP
> My SQL Server blog:http://sqlblog.com/blogs/hugo_kornelis
I was geeting a syntax error at IF...
Never mind i got it working now by properly placing the begin and end
statements
Thanks all for youe help.