Results 1 to 5 of 5

Thread: How to add new column in table in sql server

  1. #1
    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.

  2. #2
    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.

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    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;

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    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.

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    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)

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,981,859.57584 seconds with 16 queries