CASE/WHEN return type





0/5 (0 vote)
Unless you are placing this code in a stored procedure, you could just as well do this:SELECT *FROM ( SELECT 'A1' AS String1,'B1' AS String2, GETDATE() AS DateCol UNION ALL SELECT 'A2','B2', GETDATE()) AS dORDER BY And then append the sanitized column name to sort...
Unless you are placing this code in a stored procedure, you could just as well do this:
SELECT *
FROM (
SELECT 'A1' AS String1,'B1' AS String2, GETDATE() AS DateCol
UNION ALL
SELECT 'A2','B2', GETDATE()
) AS d
ORDER BY
And then append the sanitized column name to sort by before executing it.