Re: SQL query produces deferent results randomly!!!

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: raj (raj_at_discussions.microsoft.com)
Date: 10/07/04


Date: Thu, 7 Oct 2004 14:09:07 -0700

Hi Steve
I haven't had a an ORDER BY in the curser before. All this issues turned up
before having the ORDER BY statement. I'll try to explain (in brief) the
situation. Unfortunately I'm not in in a position to post any codding as a
company policy.

* I gotta temp: table(A) with a single column -A query populate userNames in
this table (This works perfectly)
* I got another temp: table(B) with 5 columns - A curser runs on table A and
obtain userNames and passes as a parameter to a query which populates table
B(this works perfectly)
*I gotta aonther curser which runs again on the table(A), obtain userNames
and passes as a parameter to a CROSS TAB query, which places all the agents
in the table A in horizontical order.(Pls refer to the table demostration of
my original question)

---97% of time the result is correct. But 3% of time get wrong(Happens
Randomly, specially in Mondays:) THe data in the table belongs to col
headings/userNames are not in the correct place when it gets wrong..(Pls
refer to the table demostration of my original question)

Now I had a ORDER BY and realeased this again. Havan't had a issue since
last Tuesday. I like to wait and see what will happen on comming Monday.

But it is hard to tell this situation occurs, bcos I do not have a ORDER BY.
According to the query, it should work without having the ORDER BY. Could u
or anyone please explain me, how this might work, or what are the
circumstances, this may work if I have an ORDER by on my last Curser.

Rellay appreciate steve, david and others ideas on this.
Thanks

raj

"Steve Kass" wrote:

> Raj,
>
> My guess is that you've got no ORDER BY clause in the query defining
> the cursor. Can't say without more info, though.
>
> Steve Kass
> Drew University
>
> raj wrote:
>
> >I 'v gotta stored procedure runs in a production database which creates a
> >report. Within the stored procedure, I 've gotta curser which grabs user
> >names from a temperory table and pass into another SQL query which
> >dinamically building a cross tab query. I found rearly this query produces an
> >inconsistace results. (Specially on Mondays). The format of the query is
> >below(Correct report)
> >----------UserA | User B | User C | User D
> >Activity1 A1 B1 C1 D1
> >Activity2 A2 B2 C3 D2
> >Activity3 A3 B3 C3 D3
> >Activity4 A4 B4 C4 D4
> >------------------------------------------------------------------
> >(Randomly get inconsistance result)
> >
> >----------UserA | User B | User C | User D
> >Activity1 A1 C1 B1 D1
> >Activity2 A2 C2 B3 D2
> >Activity3 A3 C3 B3 D3
> >Activity4 A4 C4 B4 D4
> >------------------------------------------------------------------
> >
> >I would greatly appreciate with any ideas?
> >
> >Raj
> >
> >
> >
> >
>



Relevant Pages

  • SQL query produces result randomly!!
    ... > I haven't had a an ORDER BY in the curser before. ... > obtain userNames and passes as a parameter to a query which populates table ... >> Raj, ... >> Steve Kass ...
    (microsoft.public.sqlserver.programming)
  • SQL query produces deferent results randomly!!
    ... > I haven't had a an ORDER BY in the curser before. ... > obtain userNames and passes as a parameter to a query which populates table ... >> Raj, ... >> Steve Kass ...
    (microsoft.public.sqlserver.programming)
  • Re: SELECT vs. ORDER BY - order of execution question
    ... HI Cinnie - For your original question, the answer are both yes and no: ... a particular query on the assumption that there is a definite order between ... standard convention found in most VBA and SQL texts. ...
    (microsoft.public.access.queries)
  • Query by Month and Year (Repost)
    ... I am reposting this question because I cannot access the original question ... I have a table with contribution information, with a date field for posting ... Syntax error in query expression ... In addition, will this solution work if I want to query by YEAR, so that I ...
    (microsoft.public.access.queries)
  • Re: [PHP] Getting mysql_query results into an array
    ... and don't put them into an array at all. ... query is nasty and the PHP is fast and easy, ... The original question was "what's most efficient". ... even though they appear in the original order within the raw ...
    (php.general)