Share via

Add column sql server

Laxmi 61 Reputation points
2022-03-02T03:06:50.697+00:00

hi,

I am trying to add one column in existing table with VARCHAR(50) NULL,but it showing invalid column name .I am having dbo access for that particular database. Can you please tell me why i am not able to add that particular column.

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.

SQL Server | Other
0 comments No comments

Answer accepted by question author

  1. Erland Sommarskog 133.9K Reputation points MVP Volunteer Moderator
    2022-03-02T22:29:09.563+00:00

    To add a column to a table:

    ALTER TABLE tbl ADD MyNewCol varchar(50) NULL
    

    Do not use the Table Designer in SSMS! It is rotten from the inside out! Lots of bugs, and it seems that you were bitten by one of them.


3 additional answers

Sort by: Most helpful
  1. Olaf Helper 47,616 Reputation points
    2022-03-02T06:35:13.903+00:00

    invalid column name

    There are some rules regarding valid object name you may violate, see Database Identifiers

    0 comments No comments

  2. LiHong-MSFT 10,061 Reputation points
    2022-03-02T06:06:22.13+00:00

    Hi @Laxmi
    Please provide your code that to add column and the error message you got.
    BTW,Please check if there is same column name in your table, column names in each table must be unique.

    0 comments No comments

  3. Daniel Reyes 1 Reputation point
    2022-03-02T03:36:48.483+00:00

    Hi Laxmi-1008,
    Can you post the exact command you executed, and the error received?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.