Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set bit column default value = 1

Status
Not open for further replies.

laprog

Programmer
Aug 6, 2003
10
CA
Hello everyone...
I have an already existing table with records in it.
On column of the table is of data type Bit with no default value.
I now have to put a default value on that column so that it is [True] or = 1.
When i put 1 in the default value property of this column, and i try inserting a record in the table, this column = False....
I don't understand, please help. I know it can be done by trigger but i'd rather use Default value.

Thanks! LaProg
 
>When i put 1 in the default value property of this column, and i try inserting a record in the table...

How? From Enterprise Manager, application or... ?

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Try this ... open Enterprise Manager and drill down to the database and then to the table. Right click the table and choose Design Table.

click on the bit column. On the bottom you will see the Columns tab. Enter on the DEFAULT VALUE line (1).


Thanks

J. Kusch
 
Hi everyone,
Thanks for the replies. It did help. I am still faced with a problem...since i am inserting my records through Access, it appears to me access is not supporting a default bit value of (1) or (-1) from a SQL table.
When i insert a record through SQLQueryAnalyser, i have not trouble, my bit column is equal to true.
When i insert through Access, my bit column is equal to 0.

I know this forum is for SQL problems but we never know!

Thank again! LaProg
 
A bit field can only contain a Zero (0) or a One (1) NOT a Negative One (-1)

Thanks

J. Kusch
 
The way Access does bits is different from the way SQL does bits. Either they use different #s or they use the bit in the exact opposite of each other.

I believe it is the former. -1 and 1 (or -1 and 0) for Access and 0 and 1 for SQL.

That's your problem.

BTW, Access calls a bit datatype Yes/No, not bit.



Catadmin - MCDBA, MCSA
"If a person is Microsoft Certified, does that mean that Microsoft pays the bills for the funny white jackets that tie in the back???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top