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)
 compare two bit fields in a select statement

Author  Topic 

smh
Yak Posting Veteran

94 Posts

Posted - 2008-10-26 : 15:13:17
I have two bit fields, PostToARFlag and HasBeenPosted. I want to display a field called 'ToBePosted' which is 1 if PostToARFlag = 1 and HasBeenPosted = 0 otherwise 0. How would I do the following:

select OrderId, iif((PostToARFlag = 1 and HasBeenPosted = 0), 1, 0) as ToBePosted from tblorder

Thanks

cr8nk
Yak Posting Veteran

77 Posts

Posted - 2008-10-26 : 15:29:29
SELECT
CASE WHEN PostToARFlag = 1 AND HasBeenPosted = 0 THEN 1
ELSE 0
END as ToBePosted
FROM tblOrder
Go to Top of Page

smh
Yak Posting Veteran

94 Posts

Posted - 2008-10-26 : 15:31:50
That's it. Thanks so much for the quick response.
Go to Top of Page
   

- Advertisement -