Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Different results with SQL

Author  Topic 

ASPSQLVB
Starting Member

46 Posts

Posted - 2007-01-10 : 19:55:22
Hello,

I am wondering why I am getting different results when I run this SQL statement on my public Web Server.
I get 3 rows of the same value when I want 3 rows of different values.
On my desktop I can run the below SQL Statement and recieve the data I am looking for. When I try running it on the Public Web Server, I get a different result set.

SELECT TOP 3 MAX(TotalWeight.TotalWeight) AS TotalWeight, COUNT(*) AS Expr3, COUNT(*) AS Expr4, TotalWeight.TotalWeightId, BigFish.BigFish, Fish.Fish, Fish.FishCount, FishAngler.Bio, FishAngler.AnglerPhoto, FishAngler.PegNumber, FishAngler.TeamName, FishAngler.FirstName,FishAngler.LastName, FishAngler.State, FishAngler.Country, FishAngler.Sponsor, FishAngler.SponsorWebAddress,FishAngler.AnglerPassword FROM BigFish INNER JOIN FishAngler ON BigFish.FishId = FishAngler.FishId INNER JOIN Fish ON FishAngler.FishId = Fish.FishId INNER JOIN TotalWeight ON FishAngler.FishId = TotalWeight.FishId GROUP BY TotalWeight.TotalWeightId, BigFish.BigFish, Fish.Fish, Fish.FishCount, FishAngler.Bio, FishAngler.AnglerPhoto, FishAngler.PegNumber, FishAngler.TeamName, FishAngler.FirstName, FishAngler.LastName, FishAngler.State, FishAngler.Country, FishAngler.Sponsor, FishAngler.SponsorWebAddress, FishAngler.AnglerPassword ORDER BY MAX(TotalWeight.TotalWeight) DESC

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-01-10 : 19:56:34
Are they pointing to different databases?

Tara Kizer
Go to Top of Page

ASPSQLVB
Starting Member

46 Posts

Posted - 2007-01-10 : 20:06:55
No. Database is correct.
I want 3 different rows of data to come back.

This does not work on the public server. On the public server, I get 3 rows of the same data but, it does work on my local desktop using IIS/Sql SERVER/ASP. On my local desktop I get 3 different rows of data and this is what I want. Is the SQL statement wrong?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-01-10 : 20:11:39
If both are pointing to the same database, then the query will return the same results.

You are doing something else wrong besides the query.

Tara Kizer
Go to Top of Page

ASPSQLVB
Starting Member

46 Posts

Posted - 2007-01-10 : 20:26:37
the the 3 records in a Do Until loop will load each record into a table. I just dont understand why the next record is not being loading. Its as if the Loop is not moving to the next record to then be loaded into the table.
Just keeps adding the same row of data 3 times.
I can only look at the looping code so much. I cant think were else the problem could be. I think the DO UNTIL Loop is not flowing correctly.....I guess.?...?.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-01-10 : 21:50:14
I can't help you with your application code unless it's rather trivial. I can only help with the SQL side, but I can tell you that if the query works from one machine, then the query is correct.

Tara Kizer
Go to Top of Page

ASPSQLVB
Starting Member

46 Posts

Posted - 2007-01-10 : 22:35:39
Is it possible this sql statement would produce different results?......My database, stored procedures on my Local desktop are exactly the same as the databse, stored procedures on the public Web Server.
I should get the TOP 3 Totalweight holders and I am not.
I have no idea why this works on my DESKTOP and NOT on the public Server.
Is there another way of writing this SQL statement so it brings back the 3 TOP Totalweight holders ?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-01-11 : 00:56:20
I don't know what you mean by your database, stored procedures on your local desktop and then you say database, stored procedures on the public Web server. Your wording indicates you have two different databases, one on your laptop and one on the server. I've been asking since my first post how many databases that you have. If you have more than one database and you are querying both them, then they return different result sets since the data inside them may be different.

So how many databases do you have?

What do you have on your laptop?

If you have one database and you are using one query, then it will return the same results no matter what computer you are using to query it (assuming the data doesn't change in between the querying of course).

Tara Kizer
Go to Top of Page
   

- Advertisement -