Aaron37
Technical User
- Aug 27, 2002
- 52
Hello,
I'm new to Sql Server and have a question about my primary key. I've set up my primary key clustered in ascending order. When I opened the table and returned all rows, the order of the id column was 1,10,11,110 instead of 1,2,3,4,... Even when I add order by Id to the SQL statement the order didn't change. I created an unclustered index for the same column and when I opened the table the order was the way I intended, 1,2,3,4, ...
Why would the sort order change after adding the other index? I'm sure it's propbably not a good thing to have 2 indexes for the same column but it's all I've been able to come up with. Is there a better way to do it? This is probably a silly question but like I said I'm new to SQL Server. Any help is greatly appreciated.
Thanks,
A.Davis
I'm new to Sql Server and have a question about my primary key. I've set up my primary key clustered in ascending order. When I opened the table and returned all rows, the order of the id column was 1,10,11,110 instead of 1,2,3,4,... Even when I add order by Id to the SQL statement the order didn't change. I created an unclustered index for the same column and when I opened the table the order was the way I intended, 1,2,3,4, ...
Why would the sort order change after adding the other index? I'm sure it's propbably not a good thing to have 2 indexes for the same column but it's all I've been able to come up with. Is there a better way to do it? This is probably a silly question but like I said I'm new to SQL Server. Any help is greatly appreciated.
Thanks,
A.Davis