I want To make a sql Query Dynamic mean On if else Condition i want to Add different columns into the select statement like that
If(QuestionID==1)
Select some thing
Else IF(questionID=2)
Select some thing differnt
Loading
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
Khargesh RajputRank #616 · 3.9K reputationPosted Dec 26, 2014, 8:08 PM EST
Select * from table where QuestionID=1
Else IF(questionID=2)
Select * from table where QuestionID=2
Joginder BangerRank #360 · 7K reputationPosted Dec 26, 2014, 8:12 PM EST
Make the store Procedure like this type.
create procedure Procedure_name
(
@firstParameters varchar(max),
@secondParamerts varchar(max)
)
as
begin
if(@firstParameters=='condition one')
begin
--do stuff here
end
else
if(@secondparamerts=='condition two')
begin
--do stuff here
end
end
end
Danish HabibRank #2,024 · 715 reputationPosted Dec 26, 2014, 8:17 PM EST