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
 SQL Server Development (2000)
 Dynamic order problem

Author  Topic 

didio
Starting Member

7 Posts

Posted - 2001-07-17 : 10:10:16
Hi,

Can somebody see what I'm doing wrong here?
I get this error if I supply 1 or 2 in the @sort variable.
If I supply 3 then its working.

Error:
Syntax error converting datetime from character string.

SP:
CREATE PROCEDURE sptest
@Sort int
AS
SELECT R.ResourceID, R.ResourceName, R.ShowDetails, C.CategoryName, R.Locked, R.[Date]
FROM tblResources R LEFT OUTER JOIN tblCategories C ON R.CategoryID = C.CategoryID
WHERE (R.SiteID = 1)
ORDER BY CASE
WHEN @Sort = 1 THEN R.ResourceName
WHEN @Sort = 2 THEN C.CategoryName
WHEN @Sort = 3 THEN R.[Date]
ELSE R.[Date]
END DESC
GO

Thanks.


   

- Advertisement -