Advertisement
Guest User

Untitled

a guest
Jul 6th, 2013
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. ORDER BY
  2. CASE
  3. WHEN @orderBy = 'ClientName' THEN c.LastName
  4. WHEN @orderBy = 'EmployerName' THEN cda.Name
  5. WHEN @orderBy = 'EmploymentDate' THEN cda.StartDate
  6. END
  7.  
  8. ORDER BY
  9. CASE WHEN @orderBy = 'ClientName' THEN c.LastName END,
  10. CASE WHEN @orderBy = 'EmployerName' THEN cda.Name END,
  11. CASE WHEN @orderBy = 'EmploymentDate' THEN cda.StartDate END
  12.  
  13. ORDER BY
  14. CASE
  15. WHEN @orderBy = 'ClientName' THEN c.LastName
  16. WHEN @orderBy = 'EmployerName' THEN cda.Name
  17. ELSE ''
  18. END,
  19. CASE
  20. WHEN @orderBy = 'EmploymentDate' THEN cda.StartDate
  21. ELSE '19000101'
  22. END
  23.  
  24. ORDER BY
  25. CASE
  26. WHEN @orderBy = 'ClientName' THEN c.LastName
  27. WHEN @orderBy = 'EmployerName' THEN cda.Name
  28. --gives "yyyy-mm-ddThh:mm:ss.mmm "
  29. WHEN @orderBy = 'EmploymentDate' THEN CONVERT(varchar(30), cda.StartDate, 121)
  30. END
  31.  
  32. WHEN @orderBy = 'EmploymentDate' THEN cda.StartDate
  33.  
  34. WHEN @orderBy = 'EmploymentDate' THEN cast(cda.StartDate as VarChar)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement