If a stored procedure has 3 select statements how to execut
if a stored procedure has 3 select statements how to execute a particular select statement from the stored procedure
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Abhay ShankerRank #375 · 6.7K reputationPosted Jan 6, 2014, 10:16 PM EST
DECLARE @condition INT
SELECT CASE(@intInput) WHEN 1 THEN
Select First
statement
SELECT CASE(@intInput) WHEN 2 THEN
Select Second
statement
SELECT CASE(@intInput) WHEN 3 THEN
Select Third
statement
IF @condition = 1
BEGIN
Select First
statement
END
BEGIN
Select Second statement
END
BEGIN
Select Third statement
END
Girish Sapariya159 reputationPosted Jan 6, 2014, 8:37 PM EST
you have to write the select statements in cases, and pass the case type as parameter to the procedure.
muthukumar146 reputationPosted Jan 6, 2014, 8:44 PM EST
Manish KumarRank #5,163 · 309 reputationPosted Jan 6, 2014, 8:56 PM EST
i Hope You Got Appropriate Answer
Girish Sapariya159 reputationPosted Jan 6, 2014, 9:31 PM EST
Create Procedure GetDatatemp
@casetype varchar(20)=''
As
Begin
if(@casetype = 'case1')
begin
print 'case 1' -- select statement1
end
else if(@casetype = 'case2')
begin
print 'case 2'-- select statement2
end
else if(@casetype = 'case3')
begin
print 'case 3' -- select statement3
end
End
--exec GetDatatemp 'case3'
Hope this helps you