How do I find duplicated values in related table and update them
===

This is my situation.

**TABLE1:**
DOCUMENT_ID,
GUID

**TABLE2:**
DOCUMENT_ID,
FILE

The tables are joined by DOCUMENT_ID, meaning that TABLE2 can have one or many records with same DOCUMENT_ID.

My problem is that TABLE2 values for whole bunch of DOCUMENT_IDs have same FILE values.

I need an SQL query that will get me all GUID and COUNT how many records in TABLE2 for this DOCUMENT_ID have EXACTLY THE SAME FILE value. (so i can copy the GUIDS to excell).


Then i need to UPDATE TABLE2 FILE field for this cases.
For instance if DOCUMENT_ID has three rows in TABLE2 with same FILE value, I need to update two of them by adding a postfix like FILEVALUE-1, FILEVALUE-2 and so on.

Hope i make sense.
To all experts thank you in advance.