This is a discussion on Recordset's Order and Database's Physical Order? within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi,guys! I have a table below: CREATE TABLE rsccategory ( categoryid NUMERIC(2) IDENTITY(1,1), categoryname VARCHAR(20) NOT NULL, PRIMARY KEY(categoryid) ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi,guys! I have a table below: CREATE TABLE rsccategory ( categoryid NUMERIC(2) IDENTITY(1,1), categoryname VARCHAR(20) NOT NULL, PRIMARY KEY(categoryid) ) Then I do: INSERT rsccategory(categoryname) VALUES('url') INSERT rsccategory(categoryname) VALUES('document') INSERT rsccategory(categoryname) VALUES('book') INSERT rsccategory(categoryname) VALUES('software') INSERT rsccategory(categoryname) VALUES('casus') INSERT rsccategory(categoryname) VALUES('project') INSERT rsccategory(categoryname) VALUES('disert') Then SELECT * FROM rsccategory in ,I can get a recordeset with the 'categoryid' in order(1,2,3,4,5,6,7) But If I change the table definition this way: categoryname VARCHAR(20) NOT NULL UNIQUE, The select result is in this order (3,5,7,2,6,4,1),and 'categoryname ' in alphabetic. Q:why the recordset's order is not the same as the first time since 'categoryid' is clustered indexed. If I change the table definition again: categoryname VARCHAR(20) NOT NULL UNIQUE CLUSTERED the result is the same as the first time. Q:'categoryname' is clustered indexed this time,why isn't in alphabetic order? I am a newbie in ms-sqlserver,or actually in database,and I do have sought for the answer for some time,but more confused,Thanks for your kind help in advance! |
| |||
| I assume the last post was a mistake or a late delivery from a news server, as you've got several replies to your question. If you have question on any of the replies, please ask along with the reply (and not just post the question again). -- Tibor Karaszi, SQL Server MVP Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver "Rhett Liu" <liuchenggang@mail.biti.edu.cn> wrote in message news:bikuok$9uv$1@mail.cn99.com... > Hi,guys! > > I have a table below: > CREATE TABLE rsccategory > ( > categoryid NUMERIC(2) IDENTITY(1,1), > categoryname VARCHAR(20) NOT NULL, > PRIMARY KEY(categoryid) > ) > Then I do: > INSERT rsccategory(categoryname) VALUES('url') > INSERT rsccategory(categoryname) VALUES('document') > INSERT rsccategory(categoryname) VALUES('book') > INSERT rsccategory(categoryname) VALUES('software') > INSERT rsccategory(categoryname) VALUES('casus') > INSERT rsccategory(categoryname) VALUES('project') > INSERT rsccategory(categoryname) VALUES('disert') > Then SELECT * FROM rsccategory in ,I can get a recordeset with the > 'categoryid' in order(1,2,3,4,5,6,7) > But If I change the table definition this way: > categoryname VARCHAR(20) NOT NULL UNIQUE, > The select result is in this order (3,5,7,2,6,4,1),and 'categoryname ' > in alphabetic. > Q:why the recordset's order is not the same as the first time since > 'categoryid' is clustered indexed. > > If I change the table definition again: > categoryname VARCHAR(20) NOT NULL UNIQUE CLUSTERED > the result is the same as the first time. > Q:'categoryname' is clustered indexed this time,why isn't in alphabetic > order? > > I am a newbie in ms-sqlserver,or actually in database,and I do have > sought for the answer for some time,but more confused,Thanks for your > kind help in advance! > > > |
| ||||
| Tibor Karaszi дµÀ: > I assume the last post was a mistake or a late delivery from a news server, as you've got several > replies to your question. If you have question on any of the replies, please ask along with the > reply (and not just post the question again). > late delivery, you are right, And you are so kind!Wishes! |