Jonathan Allen
Jonathan Allen

Reputation: 70317

How do I create a bit constant in T-SQL?

How do I create a bit constant in T-SQL? I tried using Convert(bit, 0) but that is having a weird effect in SSDT.

Upvotes: 0

Views: 299

Answers (2)

Robby Cornelissen
Robby Cornelissen

Reputation: 97151

I'm not sure what you mean by a weird effect in SSDT, but here's two more options you can try:

Using CAST instead of convert:

CAST(0 AS BIT)

Declaring the variables first:

DECLARE
   @True BIT,
   @False BIT;
SET @True = 1;
SET @False = 0;

Upvotes: 0

Jan
Jan

Reputation: 11

Have you tried: CAST(0 AS BIT)
Also have a look here:
Imply bit with constant 1 or 0 in SQL Server

Upvotes: 1

Related Questions