title: how to concatenate varying stored procedure parameters
body: <p>please help me with writing this search sql stored procedure
  procedure may have different number of parameters at different time 
  so could any body help me with writing this query. I don't know how to concatenate parameters. 
  i am new to stored procedure</p>
  
  <pre><code>CREATE PROCEDURE searchStudent
  -- Add the parameters for the stored procedure here
  @course int=null,
  @branch int=null,
  @admissionYear varchar(max)=null,
  @passingYear varchar(max)=null,
  @userName varchar(max)=null,
  @sex varchar(max)=null,
  @studyGap varchar(max)=null,
  @firstName varchar(max)=null,
  @lastName varchar(max)=null
  AS
  BEGIN
  -- SET NOCOUNT ON added to prevent extra result sets from
  -- interfering with SELECT statements.
  SET NOCOUNT ON;
  DECLARE query STR DEFAULT null
  
  IF @course IS NOT NULL
  THEN query=
  SELECT * FROM [tbl_students] WHERE 
  
  END
  GO
  </code></pre>
  
  <p>please complete the query so that it can have parameters which are having values and can search from database on the basis of parameters value. But parameter may vary every time depends on search criteria.</p>