Try this expression: case Gender when 'M' then 1 when 'F' then 0 end
. Use it in the corresponding parts of MERGE, or show details.
How to convert CHAR(1) to BIT in SQL SERVER
Ramana Kopparapu
306
Reputation points
Hi, I have two tables emp_source and emp_target. In Source I have 3 columns id INT Name VARCHAR(20) Gender CHAR(1) Target Table: Id INT Name VARCHAR(20) Gender BIT Assuming if Gender is 'M' which is equal to 1 and Gender is 'F' which is equal to 0 While trying to load data to Target table using MERGE Statement getting the error. Conversion failed when converting the varchar value 'M' to data type bit.. Could anyone please look into this and respond?
Accepted answer
-
Viorel 117.2K Reputation points
2024-02-03T09:19:42.1+00:00