title: Rename a column if it exists in a table
body: <p>I am trying to rename a column if it is exists</p>
  
  <pre><code>GO
  
  IF EXISTS(SELECT 1 FROM sys.columns WHERE [name] = N'MinDuration'
             AND [object_id] = OBJECT_ID(N'Category'))
  BEGIN
      sp_RENAME 'Category.MinDuration', 'SingleDuration' , 'COLUMN'
  END
  
  GO
  </code></pre>
  
  <p>But getting error <code>Incorrect syntax near sp_RENAME. Expecting CONVERSATION, DIALOG, DISTRIBUTED or TRANSACTION</code></p>
  
  <p>How can I rename my column if it exists in the table?</p>