Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 MODIFY CLAUSE IN AN ALTER TABLE STATEMENT

Author  Topic 

dlmagers10
Starting Member

48 Posts

Posted - 2010-10-27 : 10:05:45
OK, TRYING TO UPDATE [MODIFY] AN EXISTING TABLE NONAPPLIANCE

HERE IS MY STATEMENT:

ALTER TABLE NONAPPLIANCE
MODIFY DESCRIPTION CHAR(30);

IT IS GIVING ME AN ERROR:

Msg 102, Level 15, State 1, Line 2 Incorrect syntax near 'MODIFY'.

WHAT AM I DOING WRONG?

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-10-27 : 10:19:59
quote:


ALTER TABLE NONAPPLIANCE
Alter column DESCRIPTION CHAR(30);

Go to Top of Page

dlmagers10
Starting Member

48 Posts

Posted - 2010-10-27 : 10:25:39
Thank you.
Go to Top of Page

dlmagers10
Starting Member

48 Posts

Posted - 2010-10-27 : 11:34:17
Ok, I would like to ask you this if I may,

On another database I created a table named FICTION

and the table looks like this:

CREATE TABLE FICTION
(BOOK_CODE CHAR(4) PRIMARY KEY,
TITLE CHAR(40),
PUBLISHER_CODE CHAR(3),
PRICE DECIMAL(4,2) );

Now I am trying to change the data type in TITLE to CHAR(50)

ALTER



TABLE FICTION

MODIFY



COLUMN TITLE CHAR(50);

I am getting an error again:

Msg 156, Level 15, State 1, Line 2

Incorrect syntax near the keyword 'COLUMN'.

My question is do I need to REFRESH something?

Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-10-27 : 12:29:30
Existing column alter syntax is:

Alter table <tableName>
Alter column <ColumnName> <Datatype with length>


ALTER TABLE FICTION
MODIFY ALTER COLUMN TITLE CHAR(50);

Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-10-27 : 15:05:26
Modify is not part of the Alter table syntax. Please consult the SQL Books Online for what the valid syntax is.

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -