View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 06:39 PM
Tibor Karaszi
 
Posts: n/a
Default Re: Recordset's Order and Database's Physical Order?

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!
>
>
>



Reply With Quote