0

What is so strange with

SELECT 1=1 

in T-Sql ?

I'm just not able to execute it. The Editor itself says incorrect syntax but it's just a Boolean expression! enter image description here

I'm amazed. Somebody please clarify.

Sunny Sharma
  • 4,688
  • 5
  • 35
  • 73
  • 7
    Because SQL Server doesn't have a user-visible `boolean` data type? – Damien_The_Unbeliever Jul 21 '16 at 06:59
  • 1
    Possible duplicate of [Is there a Boolean data type in Microsoft SQL Server like there is in MySQL?](http://stackoverflow.com/questions/3138029/is-there-a-boolean-data-type-in-microsoft-sql-server-like-there-is-in-mysql) – GSerg Jul 21 '16 at 06:59
  • 1
    why would you be able to do that? AFAIK, the only way to write a condition in the select clause of a statement is inside a case expression. you could do this, if you really want: `SELECT CAST(CASE WHEN 1 = 1 THEN 1 ELSE 0 END as bit)` – Zohar Peled Jul 21 '16 at 07:15
  • thanks @Damien_The_Unbeliever please elaborate on "user-visible boolean data type"? any pointers...! – Sunny Sharma Jul 21 '16 at 07:24
  • @Sunny - I mean that, of course there must be times when SQL Server is evaluating predicates and probably needs to have internal variables that store the results of those evaluations. But as a *user* of SQL Server, we have no means to declare a variable of that type. – Damien_The_Unbeliever Jul 21 '16 at 07:26
  • @Damien_The_Unbeliever great, thanks. that helped! – Sunny Sharma Jul 21 '16 at 07:27

0 Answers0