Skip to content
Advertisement

add bool column within existing table

I am trying to dd a column, to a database with the program Microsoft SQL Server Management Studio.

I already have a database, with a table, in that table i need to add another column.. but it keeps saying it cannot find type bool or boolean.

my code :

ALTER TABLE table_name ADD IsOpen boolean GO

Any ideas ?

side question, any idea how to alter an existing column ? i have a column called “budget” but it needs to be “Budget”.

Advertisement

Answer

You need to use bit instead of bool datatype

ALTER TABLE table_name ADD IsOpen bit
 GO

Here some info about datatypes

Data type   Access  SQLServer   Oracle  MySQL   PostgreSQL
boolean     Yes/No   Bit         Byte   N/A      Boolean

Answer for Qustion 2

The syntax to rename a column in an existing table in SQL Server (Transact-SQL) is:

Syntax:

sp_rename 'table_name.old_column_name', 'new_column_name', 'COLUMN';

For your column :

sp_rename 'table_name.budget', 'Budget', 'COLUMN';
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement