Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I need help converting this Access IIF statement to a case statement in SQL
IIf([Table1].[Name]="A","B","C' & IIf(IsNull([Table1].[Name2]),"D","")) & IIf([Table2].[Amount]="0","0","1") AS ColumnName
I know i can't do Case When Then Else Case When Then Else. I couldn't do it when an AND?
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts
Posted - 2011-04-14 : 12:24:19
My guess would be (a bit odd)case when [Table1].[Name]='A' then 'B' else 'C' + case when [Table1].[Name2] is null then 'D' else '' end end+ case when [Table2].[Amount] = '0' then '0' else '1' end AS ColumnNameYou can nest case statements and concatenate results.Not really sure what that access statement is trying to do - it doesn't look right.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy.