i have this code
with cte1 as (
select ...... from TABLE 1......
where ......
)
with cte2 as
(
select .... from table2....
where.....
)
select cte1.id,cte2.name,cte2.last from cte1 join cte2 on cte1.id=cte2.id
what i want is get bool var from stored procedure and when it true i done want to do the join,and dont want that cte2 will be calculated(save a time)
something like:
if(@BollVar=false)
select cte1.id,cte2.name,cte2.last from cte1 join cte2 on cte1.id=cte2.id
else
select cte1.id,cte1.cat from cte1
(and here i done want the cte2 even be calculated , because i donw need that)
i know that this if is not valid on sql but i just want to show what i want
how can i do this please?
thanks
Aucun commentaire:
Enregistrer un commentaire