Logical expression field | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Logical expression field

Tell me please how to make one of returned as a recordset fields a result of boolean expression. Putting into a field string region a boolean expression makes an error
SELECT MIN(form_ord.text) AS text, MIN(project.date_reg) AS date_reg, project.n_pr, LEN(project.number2)>0 AS isrepealed FROM project INNER JOIN form_ord ON project.subnum = form_ord.subnum WHERE (project.ordstat = 1) GROUP BY project.n_pr, LEN(project.number2)>0
and using IIF function doesn’t work too. cogito ergo sum
IIf() is a function in Visual Basic. You can use this in queries in MS Access, because Access integrates the Jet database engine with the VBA environment, and so you can call VB functions from within Jet. As soon as you’re sending a query to SQL Server, Access is no longer involved with the query, and you must use SQL Server’s own functions. In this case I would use the CASE WHEN … ELSE … END construct: look it up in BOL.