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)
 Case Statement in Stored Procedure

Author  Topic 

pwcphoto
Yak Posting Veteran

69 Posts

Posted - 2005-04-13 : 21:05:44
OK back for more in the continuing saga.

I added this to the end of my SELECT FROM WHERE portion of the stored procedure and it acts like it is going through all of them. goes from .07 seconds to 17 seconds for the query, even when I select the same ORDER BY as the .07 second one.

ORDER BY CASE WHEN @para10 = 1 THEN UF_rt_Images.Rating_Total
WHEN @para10 = 2 THEN UF_rt_Images.Comment_Count
WHEN @para10 = 3 THEN UF_rt_Images.Favorite_Count
WHEN @para10 = 4 THEN UF_rt_Images.Image_View_Count
WHEN @para10 = 5 THEN UF_rt_Images.Rating_Count
ELSE UF_rt_Images.Image_ID
END DESC


@para10 is declared as a tinyint and contains one of the parameters passed by the web page.

Am I doing something wrong here?

Phil
   

- Advertisement -