Sam1604
Sam1604

Reputation: 1489

Unable to add column using ALTER

I'm creating a table using the following code

CREATE TABLE [dbo].[t_emp](
[empid] [int] IDENTITY(1,1) PRIMARY KEY NOT NULL,
[salary] [numeric](10, 2) NOT NULL,
[dept] [nvarchar](50) NOT NULL)

And also i'm trying to add column using the following code,

alter table t_emp add column ename varchar(50) not null

But i'm getting the following error,

Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'column'.

Please guide me the correct way to achieve my objective.

Upvotes: 0

Views: 77

Answers (1)

mehdi lotfi
mehdi lotfi

Reputation: 11571

Use Command without Column

Aَlter Table t_emp Add ename varchar(50) not null

Upvotes: 4

Related Questions