Transact SQL: Choosing a Boolean Expression

Query:

SELECT TOP 1 ReportInvoked , EmailSent FROM tblReportInvoker WHERE WebUserId = 12345 

This gives me two bit values. What I really want is a scalar result, which is a logical AND of these two values. Is it possible? It seems to be easy, but I do not find the syntax that will work.

Edit: Of course, the flaw in my smart plan is that it would be true if both processes fail, so the revised request is:

 SELECT TOP 1 (ReportInvoked & EmailSent) & (1 & ReportInvoked) AS 'ReportSent' FROM tblReportInvoker WHERE WebUserId = 12345 
+4
source share
1 answer
 SELECT TOP 1 ReportInvoked & EmailSent AS ReportSent FROM tblReportInvoker WHERE WebUserId = 12345 

Bitwise AND operator in Transact-SQL

+7
source

Source: https://habr.com/ru/post/1302908/


All Articles