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 2000 Forums
 Transact-SQL (2000)
 Sql Statement Returning Subset?

Author  Topic 

davidshq
Posting Yak Master

119 Posts

Posted - 2005-06-20 : 15:29:48
Hi,
I am working on an ASP.NET 2.0 program that uses SQL Server Express as the backend. I had a query: SELECT * FROM Game that returned around seventy entries. I changed the query to a stored procedure as follows:
ALTER PROCEDURE dbo.SelectAllGames
(
@varUserName varchar(200)
)
AS
select * into #templastplayed from LastPlayed where uID LIKE @varUserName
select * from Game G LEFT OUTER JOIN #templastplayed LP ON [Last Played] = LP.LastPlayedDate
/* SET NOCOUNT ON */
RETURN
And am now only receiving around 10 back. I believe this is because, for some reason, it is grabbing only those where there is a #templastplayed record, but shouldn't a left outer join prevent this?
David.

- http://www.civilwarsearch.com/
- http://www.thehungersite.com/
- http://www.grid.org/

X002548
Not Just a Number

15586 Posts

Posted - 2005-06-20 : 15:49:14
First, I aplaud you for starting to use stored procs. I believe the best model is only to allow applications EXECUTE only to sprocs.

Second, you need to get rid of SELECT *, and replace it with a column list.

Third, afre you saying that you run the exact same sql and get different results.

I wouldn't think so.

Follow the suggestions in the link below my sig



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -