4

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?

1 Answer 1

7

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the help and quick example !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.