Showing posts with label appear. Show all posts
Showing posts with label appear. Show all posts

Monday, March 19, 2012

Indexing in SQL 2000

Hello Reader

Why I am not seeing the row values as per the index set on the table?
It appears in random manner.

I think it should appear ascending as per the index set for one of the Column in Ascending.

Please guide.

*****************************************
* This message was posted via http://www.sqlmonster.com
*
* Report spam or abuse by clicking the following URL:
* http://www.sqlmonster.com/Uwe/Abuse...73eeefbc3df9e58
*****************************************On Sat, 06 Nov 2004 22:44:24 GMT, SuryaPrakash Patel via SQLMonster.com
wrote:

>Hello Reader
>Why I am not seeing the row values as per the index set on the table?
>It appears in random manner.
>I think it should appear ascending as per the index set for one of the Column in Ascending.

Hi Surya,

The rows will only appear in a specific order if you explicitly request
that order with an ORDER BY clause. Without that, SQL Server is free to
choose any order (and the optimizer will try to choose the order that can
be gotten the quickest).

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)|||Dear Hugo,

Thanks

I am trying to design a database. How can I make best Judgement that Indexing (which I am trying to fix during Diagram Desingning process)is ok.

I am able to identify the best candidate for the indexing.

Below is the details I want to understand:

Area
ZIP
City
County
District
State/Province
Country

Now I want the data retrival optimization through Index. (you can suggest another idea, also)

Entities Area,..., Country have independent tables.
Example:

Area_Table
AreaID (PK)
Area
They have relationship- one to many- if you go from Country to Area.

There is one more table:

Location_Table (PK)
LocationID
AreaID
ZIPID
CityID
CountyID
DistrictID
State/ProvinceID
CountryID
(Location_ID is further related to the Address of the contact.)

GUI has a single form to enter these details.On a save command details in all the tables -Area to Country- (individually) being inserted.
& simultaniously Location_Table is also being inserted with the details.

Following is the situation of being queried these tables:

(1) GUI user can select an Area than the related details of ZIP .., ..., ...upto Country etc. should be loaded automatically (id it is previously stored by the user entry in the database.)

(2) Contacts have to retrived on the basis of Area, ZIP, ....County. (Necessary Groupings are required )

Example:
If Contacts are queried State Wise then the Display should be

State1
District1
County1
City1
ZIP1
Area1
Area2
ZIP2
City2

County2
District2

Please Guide.

SuryaPrakash

*****************************************
* A copy of the whole thread can be found at:
* http://www.sqlmonster.com/Uwe/Forum...sql-server/5074
*
* Report spam or abuse by clicking the following URL:
* http://www.sqlmonster.com/Uwe/Abuse...b0a1ca5be7a0133
*****************************************

Wednesday, March 7, 2012

Indexes not working after converting to 2000

I detached a SQL 7 DB, copied it to a server running SQL
2000 and attached it.
The indexes don't appear to be working. I've reindexed
the tables and executed a simple query that should
display the data in date order, but it's displayed in a
random order.
The same query on the original DB in SQL 7 shows the data
in date order.
Anyone know what's going on?
There's only one index. It's a nonclustered index on two
fields. Name+date.
Thanks,
DonThis is a multi-part message in MIME format.
--=_NextPart_000_02C4_01C3B29B.F1DDDD30
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Two things:
1. Order is not guaranteed, unless you include an ORDER BY in your
SELECT.
2. You should update statistics on all user tables (preferably WITH
FULLSCAN) when upgrading a database from 7.0 to 2000.
--
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Don" <ddachner@.hotmail.com> wrote in message
news:047601c3b2c4$e3e7cfa0$a301280a@.phx.gbl...
I detached a SQL 7 DB, copied it to a server running SQL
2000 and attached it.
The indexes don't appear to be working. I've reindexed
the tables and executed a simple query that should
display the data in date order, but it's displayed in a
random order.
The same query on the original DB in SQL 7 shows the data
in date order.
Anyone know what's going on?
There's only one index. It's a nonclustered index on two
fields. Name+date.
Thanks,
Don
--=_NextPart_000_02C4_01C3B29B.F1DDDD30
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

Two things:
1. Order is not =guaranteed, unless you include an ORDER BY in your SELECT.
2. You should update =statistics on all user tables (preferably WITH FULLSCAN) when upgrading a database =from 7.0 to 2000.
-- Tom
---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"Don" wrote =in message news:047601c3b2c4$e3=e7cfa0$a301280a@.phx.gbl...I detached a SQL 7 DB, copied it to a server running SQL 2000 and =attached it.The indexes don't appear to be working. I've reindexed the =tables and executed a simple query that should display the data in date order, =but it's displayed in a random order. The same query on the original DB =in SQL 7 shows the data in date order.Anyone know what's going =on?There's only one index. It's a nonclustered index on two fields. Name+date.Thanks,Don

--=_NextPart_000_02C4_01C3B29B.F1DDDD30--|||Hi Don
The only queries that 'should' display data in a particular order are
queries that contain ORDER BY. If you were formerly getting data back in a
preferred order, you were just lucky. It was never documented or supported
that any query, using any index, would return data in any speficic order
without using ORDER BY.
OTOH, having a good index can help speed up the order by, and possibly make
a sort unnecessary, but the ORDER BY must be there in order to guarantee the
order of the rows in the result set.
--
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Don" <ddachner@.hotmail.com> wrote in message
news:047601c3b2c4$e3e7cfa0$a301280a@.phx.gbl...
> I detached a SQL 7 DB, copied it to a server running SQL
> 2000 and attached it.
> The indexes don't appear to be working. I've reindexed
> the tables and executed a simple query that should
> display the data in date order, but it's displayed in a
> random order.
> The same query on the original DB in SQL 7 shows the data
> in date order.
> Anyone know what's going on?
> There's only one index. It's a nonclustered index on two
> fields. Name+date.
> Thanks,
> Don
>|||Thanks for you help. I didn't realize I was just being
lucky :-)
Don
>--Original Message--
>Hi Don
>The only queries that 'should' display data in a
particular order are
>queries that contain ORDER BY. If you were formerly
getting data back in a
>preferred order, you were just lucky. It was never
documented or supported
>that any query, using any index, would return data in
any speficic order
>without using ORDER BY.
>OTOH, having a good index can help speed up the order
by, and possibly make
>a sort unnecessary, but the ORDER BY must be there in
order to guarantee the
>order of the rows in the result set.
>--
>HTH
>--
>Kalen Delaney
>SQL Server MVP
>www.SolidQualityLearning.com
>
>"Don" <ddachner@.hotmail.com> wrote in message
>news:047601c3b2c4$e3e7cfa0$a301280a@.phx.gbl...
>> I detached a SQL 7 DB, copied it to a server running
SQL
>> 2000 and attached it.
>> The indexes don't appear to be working. I've reindexed
>> the tables and executed a simple query that should
>> display the data in date order, but it's displayed in a
>> random order.
>> The same query on the original DB in SQL 7 shows the
data
>> in date order.
>> Anyone know what's going on?
>> There's only one index. It's a nonclustered index on
two
>> fields. Name+date.
>> Thanks,
>> Don
>
>.
>|||I didn't know that about the ORDER BY.
Thanks for your help. I'll do the Scan update statistic.
Don
>--Original Message--
>Two things:
>1. Order is not guaranteed, unless you include an
ORDER BY in your
>SELECT.
>2. You should update statistics on all user tables
(preferably WITH
>FULLSCAN) when upgrading a database from 7.0 to 2000.
>--
>Tom
>----
--
>Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
>SQL Server MVP
>Columnist, SQL Server Professional
>Toronto, ON Canada
>www.pinnaclepublishing.com/sql
>
>"Don" <ddachner@.hotmail.com> wrote in message
>news:047601c3b2c4$e3e7cfa0$a301280a@.phx.gbl...
>I detached a SQL 7 DB, copied it to a server running SQL
>2000 and attached it.
>The indexes don't appear to be working. I've reindexed
>the tables and executed a simple query that should
>display the data in date order, but it's displayed in a
>random order.
>The same query on the original DB in SQL 7 shows the data
>in date order.
>Anyone know what's going on?
>There's only one index. It's a nonclustered index on two
>fields. Name+date.
>Thanks,
>Don
>