0

Given the syntax rules shown below

  • Access: IF(Condition, ReturnIfTrue, ReturnIfValue)

  • T-SQL: CASE WHEN Condition THEN ReturnIfTrue ELSE ReturnIfFalse END

What would the below be formatted to T-SQL be?

(((IIf(IsNull(Production!Product_Title) Or Production!Product_Title Like "Process*",
"Not Started", "Started"))="Not Started") And ((Person.Type) Is Not Null)) 
  • 1
    Please be aware that (a) SQL is a language and there is a standard for it which is known as (b) the SQL Standard. (c) SQL Server is the name of a database management system, and there is a specific SQL Server edition called (d) Standard. (e) PostgreSQL is a distinct database management system. (f) T-SQL is a dialect [used in the database management systems named SQL Server and Sybase / SAP ASE] of the language called SQL. (g) PostgreSQL does not use the T-SQL dialect. – MDCCL May 21 at 20:49
2

Seems you don't have to use IIF or CASE

(
    (
    Production.Product_Title IS NULL
    OR Production.Product_Title Like 'Process%'
    )
AND Person.Type IS NOT NULL
)

FYI, Transact-SQL has IIF function starting with 2012.

UPD

If you had to return some value:

SELECT
    CASE WHEN 
        Production.Product_Title IS NULL
        OR Production.Product_Title Like 'Process%'
    THEN 'Not Started'
    ELSE 'Started'
    END AS [ProductState]
FROM YourTable
  • Thanks Denis - but would you know how to drop any strings with "Process*", "Not Started", "Started" to fall under the alias of "Not Started"? That's what the MS Access query has in the IIF. I'm also usingAccess 2016. – SQL_Noob May 21 at 14:22
  • 1
    If you had to return some value depending on conditions you would have to use either CASE or IIF. But the partial query from your question doesn't return any value. It could be a part of some WHERE clause or something. – Denis Rubashkin May 21 at 14:40
  • Perfect, thanks Denis! – SQL_Noob May 21 at 15:51
-1

(((IIf(IsNull(Production!Product_Title) Or Production!Product_Title Like "Process*", "Not Started", "Started"))="Not Started") And ((Person.Type) Is Not Null))

  • 1
    Can you please explain how this code snippet answers the question? Answers with explanations are more helpful to the future readers. – mustaccio May 21 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.