Sunday, February 26, 2012

Error with Bit datatype.

I created a table called "test" with only one column of bit data type.

I opened the table using management studio and tried to enter the number "1" It is throwing the below error

Microsoft SQL Server Management Studio

Invalid value for cell (row 1, column 1).

The changed value in this cell was not recognized as valid.
.Net Framework Data Type: Boolean
Error Message: String was not recognized as a valid Boolean.

Type a value appropriate for the data type or press ESC to cancel the change.

OK Help

But when I enter true or false it accepts it as a valid value.

When I execute the query
insert into test values (1)
the insert goes fine.

I opened table via management studio I am seeing "true" "false" as values in the table.
When I do a select in the query analyzer I am getting "1" and "0" as results.

Is this the way it is indented to work?

Santhosh

Here is my take...

When SSMS (written in VS.NET) opens a table, it is using a datagrid -and the datagrid is converting to a boolean because VS.NET doesn't have a bit datatype.

If you open a query window, and execute a SQL query that returns the data from the table, you will see that the data is indeed stored as a bit datatype [ 0/1/NULL ].

|||Arnie,
Thanks for the reply. Doesnt it sound stupid?|||I agree that there could be a bit more information available about how SSMS is working behind the scenes.|||Thats because the different UIs are owned by different groups at MS. They *might* get aligned in the future.

Jens K. Suessmeyer.

http://www.sqlserver2005.de

No comments:

Post a Comment