title: Using Merge statement inside a cursor
body: <p>We have a requirement to populate a master table which consists of columns from a set of 20 different tables.</p>
  
  <p>I have written a stored procedure to join some of the tables that return me max number of columns and have them in a cursor.</p>
  
  <p>Now. I am using for loop to iterate through the cursor records so I can insert them into the master table.</p>
  
  <p>How I can use a merge statement inside the cursor for loop so I can check if I need to update existing row or insert a new row depending if the records already exists or not.</p>
  
  <p>Any ideas if we can use merge statement inside a cursor for loop? Any examples?</p>