I have a table with CountryName and an id.
Eg.
id CountryName
-----------------
1 Afghanistan
2 Afghanistan
3 Afghanistan
4 Albania
5 Albania
6 Albania
7 Albania
I want to add a new column CountryID where all the repeating CountryName will have a distinct CountryID like below.
Eg.
id CountryName CountryID
-----------------------------
1 Afghanistan 1
2 Afghanistan 1
3 Afghanistan 1
4 Albania 2
5 Albania 2
6 Albania 2
7 Albania 2
I have many countries that keep repeating and I want to add a CountryID to them to make it easier to do joins. Is it possible to do it by a T-Sql script?