Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert Bool from Access Query into SQL Server database

I am not sure how to insert boolean values from an Access query into a SQL Server table.

Access generally uses 0 for false, -1 for true. In SQL Server it's 1 for true.

So my question is this: if I want to insert a true value into my SQL Server table, can I just say -1 anyway, and SQL Server will know how to interpret it? Or do I have to put the 1 for true ?

EDIT: additionally, is it possible to just put true instead of a numeric value into the insert statement?

like image 566
Dagon313 Avatar asked Oct 29 '25 10:10

Dagon313


1 Answers

Quick sample to illustrate:

CREATE TABLE BoolTest(SomeText VARCHAR(50), SomeBool BIT)

INSERT INTO dbo.BoolTest (SomeText, SomeBool)
VALUES ('Text 1', 0), (`Text 2', 1), ('Text 3', -1)

SELECT *
FROM dbo.BoolTest

I get this result:

enter image description here

So SQL Server interprets anything other than 0 as a True value.

like image 85
marc_s Avatar answered Oct 31 '25 08:10

marc_s



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!