0

I have a table in SQL Server 2008, which has a column having datatype tinyint. Recently I noticed some very strange behavior. When doing something like

update mytable 
set mytinyint = 0 
where id = 1

The value in the column mytinyint is NULL. The query below

update mytable 
set mytinyint = NULL
where id = 1

also results in the value being NULL. And finally this query

update mytable 
set mytinyint = 1
where id = 1

sets the value to to 1.

So my question is: why can't a store the value 0 in a column which should be capable of storing any value between 0 and 255 and NULL??

Pieter
  • 3,339
  • 5
  • 30
  • 63
  • 2
    A [quick test](http://data.stackexchange.com/stackoverflow/query/77224) shows that there must be something else going on for you. `tinyint` can have `0` as value. Do you have a trigger on your table? – Mikael Eriksson Aug 13 '12 at 10:18
  • Thanks for the tip. There actually was a trigger in the database which did exactly that. – Pieter Aug 13 '12 at 10:35

0 Answers0