T-SQL-Adding a column to a table

  • Here is the script:

    ALTER TABLE password

    ADD COLUMN Domain varchar(50) NOT NULL

    GO

    Keep getting as a result:

    Msg 156, Level 15, State 1, Line 2

    Incorrect syntax near the keyword 'COLUMN'.

    I've noticed that none of these work (ADD COLUMN, ALTER COLUMN) in SQL. What am I missing?

    Thanks,

    Jeff

  • You don't need the word COLUMN.

    ALTER TABLE passoword

    ADD Domain varchar(50) NOT NULL

    GO

    If there's already data in the table, you won't be able to add the NOT NULL column unless you also supply a default value for it.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply