Link to home
Start Free TrialLog in
Avatar of Sanjay
SanjayFlag for United States of America

asked on

ms sql primary index out of sequence

I am totally new to mssql.  In my data source, I have a table called iitdata that has a primary key called IITReportNo that has a unique identity and incremented by 1.  As of late, when I open the table, I have noticed the records to be jumbled by IITReportNo.  I am using a front end ms access database that has forms and when the users use the form to try to go to a record (say 3), they end up viewing record something else other than 3.  I am asking for help to rebuild or to sort the sql iitdata table in ascending order by the primary key IITReportNo.  Some IT person told me that this involves "blowing out the key and rebuilding it"...No idea what that means.  
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

is your primary key is a clustered index? why not just add a ORDER BY clause to your query?
Avatar of Sanjay

ASKER

yes clustered index..........not sure what that means but looked up the index under the "Manage indexes"
ASKER CERTIFIED SOLUTION
Avatar of stehardy88
stehardy88
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sanjay

ASKER

WOW that worked.  Thank you so much stehardy
a clustered index is an index that physically sorts the table as per that key. do you have a ORDER BY clause in your access form?
Avatar of Sanjay

ASKER

yes i have that order by in my access form but am trying to also ensure that the sql iitdata table ALSO has the IITReportNo in ascending order...............
SELECT * FROM iitdata
ORDER BY IITReportNo ASC

Open in new window

Avatar of Sanjay

ASKER

yes did that also.  thx.