Link to home
Start Free TrialLog in
Avatar of Richardsoet
Richardsoet

asked on

sql TABLE

CREATE TABLE AGDEBTP (
  AGM3TA  VARCHAR  (32)     NOT NULL,
  AGM4TA  VARCHAR  (216),
  AGFASW  CHAR     (1)      NOT NULL ) ON [Data]  

ALTER TABLE AGDEBTP ADD CONSTRAINT AGDEBTP_PK PRIMARY KEY (
  AGM3TA)

FROM ABOVE TABLE AM TRYIN G TO ADD
AGATVC  VARCHAR  (216)                 NOT NULL)

PLEASE ADVICE THE RIGHT SCRIPT TO ADD
AGATVC  VARCHAR  (216)                 NOT NULL)
TO THE ABOVE TABLE, IT SQL 2000
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Richardsoet
Richardsoet

ASKER

I HAVE DONE THAT I WAS GETTING ERROR

ALTER TABLE only allows columns to be added that can contain nulls or have a DEFAULT definition specified. Column 'AGATVC' cannot be added to table 'AgDEBTP' because it does not allow nulls and does not specify a DEFAULT definition.
You cannot not add a column to a table with existing data that doesn't allow nulls and doesn't have a default value becuase it doesn't knwo what value to assign for those pre-existing records.

ALTER TABLE ABDEBTP
ADD COLUMN AGATVC VARCHAR(216) NOT NULL DEFAULT ''
WHEN RUN THE ABOVE SCRIPT
ERROR MESSAGE

Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'COLUMN'.
D'OH, SORRY, you're right.

ALTER TABLE ABDEBTP
ADD AGATVC VARCHAR(216) NOT NULL DEFAULT ''