September 24, 2008 at 7:26 pm
Jeff Moden (9/24/2008)
Folks, please... go back and look at the original post... the queries are identical except for the IF and the WHERE... just move the IF to the WHERE and be done with it.
Whenever someone posts generic code like in th original post I always assume they have over simplified so I try to provide an answer that will work in a more complex situation.
Hey, if the logic can be moved to the where clause with CASE or some other method great, but if not then "child" procs are the only other way to do it.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
September 24, 2008 at 8:17 pm
Jeff Moden (9/24/2008)
Hey MATT! Congrats on becoming a proud member of the over 5k crowd!
Is it just me or is the air thinner up here????:D
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
September 24, 2008 at 11:05 pm
There's air?
--Jeff Moden
Change is inevitable... Change for the better is not.
September 25, 2008 at 12:04 pm
Create a table with queries and conditions,
Loop through the cursor and match the condition with the condition value from the table and get the query
something like
declare c cursor for
SELECTcondition,[QUERY_NAME] from dbo.table
open c
fetch next from c into @condition , @QUERYNAME
while @@fetch_status=0
BEGIN
if @yourcondition_in_code = condition
begin
select @QUERYNAME
end
FETCH NEXT
END
September 25, 2008 at 4:48 pm
Wait for it...
🙂
September 30, 2008 at 7:01 am
Thanks for all the help Guys !! Will try to find out the best solution for my scenario...
September 30, 2008 at 7:53 pm
Dave (9/25/2008)
Wait for it...🙂
Heh... too easy... not even going to bother. 😛 I just shake my head and wonder. :Whistling:
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 16 through 21 (of 21 total)
You must be logged in to reply to this topic. Login to reply