Converting Boolean to Integer SQl Server Converting Boolean to Integer SQl Server sql sql

Converting Boolean to Integer SQl Server


What you are doing should be enough to convert BIT values to int as shown below.

DECLARE @TABLE TABLE(Value BIT)INSERT INTO @TABLE VALUES (1),(0),(1),(0),(1),(0),(1)

Query

SELECT  Value       ,CAST(Value AS INT)  AS Casted       ,CONVERT(int, Value) AS ConvertedFROM @TABLE 

Result Set

╔═══════╦════════╦═══════════╗║ Value ║ Casted ║ Converted ║╠═══════╬════════╬═══════════╣║     1 ║      1 ║         1 ║║     0 ║      0 ║         0 ║║     1 ║      1 ║         1 ║║     0 ║      0 ║         0 ║║     1 ║      1 ║         1 ║║     0 ║      0 ║         0 ║║     1 ║      1 ║         1 ║╚═══════╩════════╩═══════════╝