title: How to Fix Conversion failed when converting the varchar value data type int
body: <p>I want to create a stored procedure that return a value with passing a parameter.</p>
  
  <p>When I execute this stored procedure, this error occurs:</p>
  
  <blockquote>
    <p>Conversion failed when converting the varchar value 'AND GenderId=' to data type int.</p>
  </blockquote>
  
  <p>My code:</p>
  
  <pre><code>create proc sp_getPatientRegistration (@genderId int) AS
  declare @condition  varchar(500);
  begin
  If @genderId!=0
  SET @condition='AND GenderId='+@genderId
      SELECT PtRegNo,Name,MobileNo,GenderId FROm tbl_PATIENT_REGISTRATION WHERE 1=1 +@condition
  end
  </code></pre>
  
  <p>Expected result is shown in this screenshot:</p>
  
  <p><a href="https://i.stack.imgur.com/qdu5C.jpg" rel="nofollow noreferrer">Image</a></p>