SQL Server中的布尔类型为bit类型,可以取1,0或null

解决方案 »

  1.   

    那插入的时候是插入F ? false ?我想插入false让它自动保存为0,这样可不可以?有没有其他的什么办法,呵呵
      

  2.   

    另外插入的时候是写false还是'false'???谢谢大家!!!!
      

  3.   

    bool型的还是用BIT好 
    if 变量='false' then
      sql=insert into test (isOK) values(0)
    else
      sql=insert into test (isOK) values(1)
    end if
      

  4.   

    非得这样只有自己写个转换
    create table #t1 (sn bit,
    des varchar(10)) declare @strVar as varchar(10)
     set @strVar = 'xx'
     insert into #t1 values(case lower(@strVar) when 'false' then 0 when 'true' then 1 else    null end,'xx')
     declare @strVar as varchar(10)
     set @strVar = 'false'
     insert into #t1 values(case lower(@strVar) when 'false' then 0 when 'true' then 1 else    null end,'false')SELECT * FROM #T1
    /*
    sn   des        
    ---- ---------- 
    NULL   xx
    0    false
    (2 row(s) affected)
    */