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.
| 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 dataCASE 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 syntaxCASE 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 beCASE @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.BENECOUNTRYElse ' ' END,CASE @SORT When 'Beneficiary' THEN PBSA.dbo.activityhist.BENECOUNTRY ELSE 1END ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|