8

In a sql table I have a bit field and the value is displayed as True, when I update in code Update table1 set Active='True' it makes the update but the value is now displayed as 1 instead of True. How do I make it put the value 'True' instead of the integer in the table? Thanks.

Aaron Kurtzhals
  • 2,036
  • 3
  • 17
  • 21
user282807
  • 905
  • 3
  • 13
  • 26
  • 1
    What RDBMS and what is displaying the value as `True` and then `1`? – Martin Smith Jul 29 '11 at 23:29
  • it's seql version 10.50.1600.1, when i open the table to view the existing data the value is True in the Active(bit) field. Now when i do an update in management studio thru a query, it sets that value to 1. So my old value in the table is now 1 instead of True. – user282807 Jul 29 '11 at 23:34

1 Answers1

15

Bits in SQL Server are always stored as 1 or 0 in a bitmap.

The "Edit Table" option in SSMS just translates this to True or False for presentation purposes, this is nothing to do with how it is actually stored.

Martin Smith
  • 438,706
  • 87
  • 741
  • 845
  • Was getting confused when doing a select query. – user282807 Jul 29 '11 at 23:42
  • @user - Yes. If you wanted it returned as a string you would need to do `CASE Col when 1 THEN 'True' WHEN 0 THEN 'False' END` or apply such formatting in the presentation layer. – Martin Smith Jul 29 '11 at 23:42