I have a SQL Server table with fields: id, city, country. I imported this table from Excel file, everything is imported successfully, but id field is not ordered by number. The tool I use imported the rows in some random number.
What kind of Update command I should use from SQL Server Management Studio Express to re-order my ids?
Do you have a primary key and a clustered index on your table? If not,
idis a good candidate for a primary key and when you create that the primary key it will be the clustered index.Assuming this is your table
And you add data like this.
The output of
select * from CityCountrywill beA column that is primary key can not accept null values so first you have to do
Then you can add the primary key
When you do
select * from CityCountrynow you get