View Full Version : Adding checkbox colums to DB table (ALTER TABLE)

12-12-2003, 05:30 PM
Hi all,
I'm trying to add a checkbox column to a table in my db.
I have been able to add a text column but can't seem to find the right instruction to add a check box.

Any ideas?

This is the code I'm using to add a text column:
set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = vMyConnection
Command1.CommandText = "ALTER TABLE ShopTblCountries ADD ColumnName VARCHAR(10);"
Command1.Execute()Further thought:
The value, if possible, needs to be pre-set to 'True'

12-12-2003, 09:31 PM
You are not going to be bale to add a text box, but you can add a bollean column that will hold True or false and then when you write your code to the page you would have to right out checkboxes.


12-15-2003, 11:26 AM
Thanks, (and sorry for the delay in replying)

It's a great shame that it doesn't seem to be possible to add a check box column.

Does anyone know the SQL to add a value to all fields in the new column being created?

12-15-2003, 02:33 PM
If I understand you right, you would just

"UPDATE tableName SET fieldName = 'yourvalue'"

12-15-2003, 02:48 PM
Thanks, Thought of that, was just wondering if it could be done whilst creating the column.

For those who would like to know, I've actually discovered a way to create a checkbox column.
Just working on a way to set it's default value:
ALTER TABLE ShopTblCountries ADD FirstCheckBox BIT

Any ideas anyone?
Have tried
ALTER TABLE ShopTblCountries ADD FirstCheckBox BIT DEFAULT 1 but no good (syntax error)

Think I may just run an update