2
Answers

How to append Queries in Stored Procedure based on condition

How could I write this in sql stored procedure?

Hi All,
I need to append my queries based on the condition how could i do this in stored procedure


StringBuilder query
= new StringBuilder();    
**query.AppendLine("Select * from xxx Where 1 =1");**

if(Id != 0)    
query
.AppendLine("And Id = @Id");

if(Nemae != null)    
query
.AppendLine("And Name = @Name");


Thanks in Advance..
Answers (2)