How to alter table in sql server [Resolved]

Posted by Jitendrasoft09 under Sql Server on 6/26/2013 | Points: 10 | Views : 764 | Status : [Member] [MVP] | Replies : 3
Hi All,
I want to understand How to alter table in sql server, let me know if anybody knows.

Jitendra Kumar
If my post helps you, plz mark as an answer.



Responses

Posted by: Satyapriyanayak on: 6/26/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.

To add a column in a table, use the following syntax:

ALTER TABLE table_name
ADD column_name datatype

To delete a column in a table, use the following syntax (notice that some database systems don't allow deleting a column):

ALTER TABLE table_name
DROP COLUMN column_name

If this post helps you mark it as answer
Thanks

Jitendrasoft09, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Neeraaj.Sharma on: 6/27/2013 [Member] Starter | Points: 25

Up
0
Down



Syntax : ALTER TABLE table_name ADD column_name datatype


Example Below :


Create Table MyFirstTable (ID Int ) -- to create new table


ALTER TABLE MyFirstTable Add Remarks varchar(200) NOT NULL



Visot my blog http://www.tutorialsqlserver.com/

Jitendrasoft09, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jitendrasoft09 on: 6/27/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Thanks Neeraj..., Nice explanation Satya....

Jitendra Kumar
If my post helps you, plz mark as an answer.

Jitendrasoft09, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response