• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1516
  • Last Modified:

boolean where clause in sql server

What is wrong with this syntax?
I have a bit field called Active in TableA.

SELECT * FROM TableA WHERE Active

Q: Why do I have to say:
SELECT * FROM TableA WHERE Active=1

0
psenn
Asked:
psenn
3 Solutions
 
LimbeckCommented:
because you dont have a expression if you only use active

SELECT * FROM TableA WHERE Active=True
0
 
psennAuthor Commented:
Invalid column name 'True'.
0
 
LimbeckCommented:
hm its a bitfield; =1. sorry, posted too fast.

If you dont use where active=1 your statement will say 'where true'..just true isnt an expression nd thats why you get an syntax error
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
psennAuthor Commented:
I'm just miffed because other languages allow boolean expressions such as:
IF X THEN

0
 
Sham HaqueSenior SAP CRM ConsultantCommented:
(simple)SQL syntax for SELECT is as follows:

SELECT field
FROM table
WHERE field=value
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
>I'm just miffed because other languages allow boolean expressions such as:
Each language has its own syntax an semantics
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now