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)
 sort parameters

Author  Topic 

sharonmtowler
Starting Member

12 Posts

Posted - 2010-05-13 : 11:36:50
I have a stored proc. that i create a parameter to sort the data

CASE When @SORT = 'Beneficiary'
Then PBSA.dbo.activityhist.BENECUSTID
PBSA.dbo.activityhist.BENECOUNTRY
When @SORT = 'BookDate'
Then CONVERT(varchar(10), PBSA.dbo.ActivityHIST.BookDate, 112)
When @SORT = 'Bene_Country'
Then PBSA.dbo.activityhist.BENECOUNTRY
Else ' ' END SORTKEY

if i want to have it do a 2nd sort by country whats the syntax
CASE When @SORT = 'Beneficiary'
Then PBSA.dbo.activityhist.BENECUSTID
PBSA.dbo.activityhist.BENECOUNTRY

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-13 : 11:44:41
you cant return two columns inside same CASE WHEN condition. it should be

CASE @SORT When 'Beneficiary'
Then PBSA.dbo.activityhist.BENECUSTID
When 'BookDate'
Then CONVERT(varchar(10), PBSA.dbo.ActivityHIST.BookDate, 112)
When 'Bene_Country'
Then PBSA.dbo.activityhist.BENECOUNTRY
Else ' ' END,
CASE @SORT When 'Beneficiary'
THEN PBSA.dbo.activityhist.BENECOUNTRY
ELSE 1
END



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -