Jump to content
Sign in to follow this  
sambuddy

INSERT a "bit" using SQL

Recommended Posts

sambuddy

Hello All,

I have a table with a "bit" field in it BUT i am unable to insert a bit into it using autoit. Can anyone share some advice on how to represent a "bit" in autoit?

e.g. Trying to insert a "bit" into the database I have tried the following queries.

"INSERT INTO Picture_Table(True_False) VALUES (TRUE)"

"INSERT INTO Picture_Table(True_False) VALUES (1)"

"INSERT INTO Picture_Table(True_False) VALUES (Binary(1))"

But none of them work

Thanks for your help

Share this post


Link to post
Share on other sites
PsaltyDS

Hello All,

I have a table with a "bit" field in it BUT i am unable to insert a bit into it using autoit. Can anyone share some advice on how to represent a "bit" in autoit?

e.g. Trying to insert a "bit" into the database I have tried the following queries.

"INSERT INTO Picture_Table(True_False) VALUES (TRUE)"

"INSERT INTO Picture_Table(True_False) VALUES (1)"

"INSERT INTO Picture_Table(True_False) VALUES (Binary(1))"

But none of them work

Thanks for your help

This is not an AutoIt question, it is about the version of SQL you are talking to, and can be version dependent.

With Microsoft SQL 2005, at least, the BIT field is actually and integer, not a Boolean. So you need 1 or 0. Not "1" or "0" (string characters), or True/False (Boolean) because T-SQL won't translate. Your second example looks right to me: "INSERT INTO Picture_Table(True_False) VALUES (1)"

However, on a more general level, are you really trying to INSERT a new row with only the BIT value in a single existing BIT field, and all other columns null? Are all those other fields allowed to be null in a new row? Did you mean to UPDATE that bit on an existing row?

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.