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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhay ShankerPosted Jan 7, 2014, 3:16 AM
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 SapariyaPosted Jan 7, 2014, 2:31 AM
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
Manish KumarPosted Jan 7, 2014, 1:56 AM
i Hope You Got Appropriate Answer
muthukumarPosted Jan 7, 2014, 1:44 AM
Girish SapariyaPosted Jan 7, 2014, 1:37 AM
you have to write the select statements in cases, and pass the case type as parameter to the procedure.