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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Case Statement (Access to SQL)

Author  Topic 

Brittney10
Posting Yak Master

154 Posts

Posted - 2011-04-14 : 12:25:09
I'm trying to figure out how to convert this Access IIF statement to a SQL case statement:

IIf([TableA].[Name]="A","A","B"
& IIf(IsNull([TableA].[Name2]),"No Name",""))
& IIf([TableB].[Amount]="0","0","1") AS columnName,


Not sure how to integrate the ANDs into this. You can't do CASE THEN WHEN ELSE AND CASE THEN WHEN ELSE. Any help or pointers would be appreciated.

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-04-14 : 12:26:41
Duplicate post
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=159474

==========================================
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.
Go to Top of Page

sharona
Yak Posting Veteran

75 Posts

Posted - 2011-04-15 : 09:59:52
case when [TableA].[Name]in ('A','A','B') then ????
when ([TableA].[Name2] is null then 'No Name'
when [TableB].[Amount]in (0,0,1) then ????
end AS columnName,
Go to Top of Page
   

- Advertisement -