Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 02-02-2010
Member
 
Join Date: Aug 2009
Posts: 59
How to add new column in table in sql server

Hello to all,
I am new to this forum. I recently started learning SQL language. I have created one table in SQL 2005 server. This table has 5 columns. I want to add new column to this table but I don't know how to do this. Can anyone tell me how to add new column in table in sql server. Please help me.
Reply With Quote
  #2  
Old 02-02-2010
Member
 
Join Date: Nov 2005
Posts: 1,323
Re: How to add new column in table in sql server

Hey it is very easy process. In this situation you have to use Alter table command. You can do this in following example. In following program I have create one column with size 20.

Code:
ALTER TABLE dbs.UserMaster1 ADD UserType VARCHAR(20) NULL;
This code may change position of your column in table.
Reply With Quote
  #3  
Old 02-02-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: How to add new column in table in sql server

You have to use alter table query to do this. I have written Syntax of alter table query. Just try to understand it.

Alter Table:
Alter Table TableName add ColumnName datatype

In above syntax you have to use table name of yours and then add column name to it with proper size.
For Eg.

ALTER table Student ADD marks datatype constraints;
Reply With Quote
  #4  
Old 02-02-2010
Member
 
Join Date: May 2008
Posts: 2,383
Re: How to add new column in table in sql server

For adding new column in table in sql server 2oo5 you have to use The ALTER TABLE Statement. It is very easy process. Just remember syntax of it. The ALTER TABLE statement in SQL is used to add columns in an existing table.
If you don't know syntax of it then use following.

ALTER TABLE table_name
ADD column_name datatype

Where table_name is name of your table and column_name is the name of your column that you are want to add.
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #5  
Old 02-02-2010
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: How to add new column in table in sql server

There is only one way through which you can add new column in table in sql server. You have to use Alter Table to do this. If you don't know how to do this then look at following example.
Suppose your table name is "Employee" and you want to add column with name "salary" , then you can do this in following way.

Code:
Alter Table Employee ADD salary varchar(20)
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to add new column in table in sql server"
Thread Thread Starter Forum Replies Last Post
What is the way to sum up number of column in Pivot Table Dvimida MS Office Support 2 09-02-2012 07:31 PM
How to use table column as data validation list connoisseur MS Office Support 2 13-01-2012 06:10 PM
Excel Macro querying a table by column name Halyn Software Development 3 14-10-2009 08:59 PM
Determining table's column name in sql server Jinendra Windows Software 3 10-06-2009 12:14 AM
Displaying the column names of a table on a page ricardoramey Software Development 4 04-08-2008 01:31 PM


All times are GMT +5.5. The time now is 01:01 PM.