title: Add character to selected duplicate value in SQL
body: <p>I need to add character / number to selected duplicate values.</p>
  
  <p>This is what I need:</p>
  
  <pre><code>SELECT Name -- Here I need to add for example 1 if It have duplicates
              -- If It is hard way to code, how to add 1 to all selected values?
  FROM Example
  WHERE Id BETWEEN 25 AND 285
  </code></pre>
  
  <p>If there are 2 equal names <code>Peter</code> It should select <code>Peter</code> and second <code>Peter1</code></p>
  
  <p><em>If there is no easy way to make It, how to add <code>1</code> to all selected lines? Should select <code>Peter1</code> instead of <code>Peter</code></em> </p>
  
  <p>I've tried this:</p>
  
  <pre><code>SELECT Name + ' 1' AS Name -- in this case selecting wrong column
  FROM Example
  WHERE Id BETWEEN 25 AND 285
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>SELECT @cols += ([Name]) + ','
      FROM   (SELECT  Name --I neeed to integrate It here
              FROM    FormFields
              WHERE   ID BETWEEN 50 AND 82
              ) a 
  </code></pre>
  
  <p>If I use this:</p>
  
  <pre><code>SELECT @cols += ([Name]) + ',' -- here throws error
  FROM   (SELECT Name + CASE WHEN RowNum = 1 THEN '' ELSE CONVERT(NVARCHAR(100), RowNum-1) END AS [UpdatedName]
                  FROM (
                  SELECT  Name AS Name,  
                          ROW_NUMBER() OVER (PARTITION BY Name ORDER BY Name) AS "RowNum"
                  FROM    FormFields
                  WHERE   Id Between 50 And 82) x
          ) a
  </code></pre>
  
  <p>It throws error: <code>Invalid column name 'Name'.</code></p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>It's different tests but some of them have the same criteria. That's why I need It to rename.
  <img src="https://i.stack.imgur.com/hhdDM.png" alt="howshouldbe"></p>