Vishwas Kadamannaya

Vishwas Kadamannaya

  • 1.6k
  • 122
  • 142.5k

How to append Queries in Stored Procedure based on condition

Mar 24 2011 2:43 AM
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)