title: using if statement how to replace values
body: <p>I have two tables,</p>
  
  <p><strong>Database 1:</strong></p>
  
  <p><strong>Table 1:</strong></p>
  
  <ul>
  <li><p>Id -001(int)</p></li>
  <li><p>Name -xxx(varchar)</p></li>
  <li><p>Male -0 (bit)</p></li>
  <li><p>Female-1 (bit)</p></li>
  </ul>
  
  <p><strong>Database 2:</strong></p>
  
  <p><strong>Table 2:</strong></p>
  
  <ul>
  <li><p>Id -1 (int)</p></li>
  <li><p>Ca.Name-yyy (varchar)</p></li>
  <li><p>Gender - M or F (varchar)</p></li>
  </ul>
  
  <p>These are my tables. I want to update data from database2, Table 2 to database1, table1. So i create update query. But I have problem with Gender field</p>
  
  <pre><code>Select 'UPDATE T1
   SET T1.MALE ='+ CASE WHEN r.Gender = 'M' THEN 0 ELSE 1 END
  
   FROM T2 As r
  </code></pre>
  
  <p>In the below code, what I starred I have a doubt how to use if statement here. Any one understand rectify my problem?</p>