Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Column

Author  Topic 

kashyap_sql
Posting Yak Master

174 Posts

Posted - 2010-07-22 : 06:48:57
how to add a new column to existing table ex: the name of the table is workbook and i want to add "references" to the table

Kashyap M

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-07-22 : 07:11:14
You need to know what datatype it should be and if the new column is allowed to be NULL

alter table workbook
add [references] varchar(255) NULL



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

kashyap_sql
Posting Yak Master

174 Posts

Posted - 2010-07-22 : 08:02:10
the references must not null so i will put not null instead of null

Kashyap M
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-07-22 : 08:07:45
You'll need to add a default to the column if you declare it NOT NULL, otherwise you'll get an error.
Go to Top of Page

kashyap_sql
Posting Yak Master

174 Posts

Posted - 2010-07-22 : 08:09:11
quote:
Originally posted by robvolk

You'll need to add a default to the column if you declare it NOT NULL, otherwise you'll get an error.


i can't get you can give clarity i am getting the error

Kashyap M
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-07-22 : 08:53:39
Do you have already data in the table?
If yes - what should be the value for these rows while adding the new column which can't be NULL?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

kashyap_sql
Posting Yak Master

174 Posts

Posted - 2010-07-22 : 08:58:58
i created a table that name is work sheet in that i want to add a column references which means the books or names of the authors

Kashyap M
Go to Top of Page
   

- Advertisement -