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 2005 Forums
 Transact-SQL (2005)
 Covert Access VBA to T-SQL

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2009-10-20 : 08:55:51
I am so confused IIF in VBA. For example, I need to conver the following VBA to T-SQL, can someone help me?

WHERE (((CLAIMNO) Like Year(Date())
& IIf (Month(Date())<10,
"0" & Month(Date()),
Month(Date()))
& IIf (Day(Date())<10,
"0" & Day(Date()),
Day(Date()))
& IIf ([Operator]<10,
"00" & [Operator],
IIf([Operator]<100,
"0" & [Operator],
[Operator])) & "*"))

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2009-10-20 : 09:30:58
IFF => CASE

have a go at some simple constructs in SQL and try to transpose any lessons learnt to working this code out. come back to the forum if really stuck.
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-10-20 : 09:55:03
I believe a lot of your code can be solved with this
select convert(varchar(10),date,112)+ right('00'+operator',3)

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -