convert to bit

  • I have data in column1 having datatype -varchar (4)) with 2 values - Yes or No

    I want to insert this data into other tables column2 having datatype -bit.

    how to do that?

  • bang.prashant (9/30/2008)


    I have data in column1 having datatype -varchar (4)) with 2 values - Yes or No

    I want to insert this data into other tables column2 having datatype -bit.

    how to do that?

    insert into secondtable (column2)

    select Cast(case when column1 = 'Yes' then 1 when column1 = 'No' then 0 end as bit)

    from firsttable

  • thanks

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply