IIF/CASE statement in a SQL Server VIEW
Posted on 2006-10-27
Experts, in my Select statement I want split a transaction column into credits and debits, in SQL Server. I have opened the SQL Query Analyzer and typed:
CASE WHEN tran > 0 THEN tran ELSE 0 END as credits, CASE WHEN tran < 0 THEN abs(tran) ELSE 0 END as debits FROM transactions
And it works great...
But when I open a new VIEW and enter the same working code, I get an error: "The Query Designer does not support the CASE SQL construct." And it won't allow me to save the view. Is there a way I can do an IIF type statement in the Query Designer, that will actually let me save it as a VIEW?