In SQL Server, you can use 'TRUE' and 'FALSE' string constants with the BIT data type. TRUE and FALSE keywords use is also allowed in some contexts but it is very limited (see below).
In PostgreSQL, you can use 'TRUE' and 'FALSE' string constants as well as TRUE and FALSE keywords to represent boolean values.
SQL Server:
DECLARE @var BIT = 'FALSE' PRINT @var /* Result: 0 */ SET @var = 'TRUE' PRINT @var /* Result: 1 */ -- You cannot use 'FALSE' and 'TRUE' with other data types DECLARE @var2 INT = 'FALSE' /* Msg 245, Level 16, State 1, Line 1 */ /* Conversion failed when converting the varchar value 'FALSE' to data type int. */
PostgreSQL:
DO $$ DECLARE var BOOLEAN = 'FALSE'; var2 BOOLEAN = TRUE; BEGIN RAISE NOTICE '%', var; /* Result: f */ RAISE NOTICE '%', var2; /* Result: t */ END $$;
SQL Server allows you to use 'TRUE' and 'FALSE' string literals, not TRUE and FALSE keywords to assign values to BIT:
SQL Server:
-- TRUE and FALSE keywords are not allowed in assignment DECLARE @var BIT = TRUE /* Msg 207, Level 16, State 1, Line 1 */ /* Invalid column name 'TRUE'. */
But you can use TRUE and FALSE keywords for default values for parameters in user-defined functions:
SQL Server:
-- Sample function using FALSE and TRUE keywords CREATE FUNCTION bit1(@param1 BIT = FALSE, @param2 BIT = TRUE) RETURNS INT BEGIN IF @param1 = 0 AND @param2 = 1 RETURN 3 RETURN 0 END GO /* Commands completed successfully. */ -- Calling the function SELECT dbo.bit1(DEFAULT, DEFAULT); /* Result: 3 */
For more information, see SQL Server to PostgreSQL Migration.