tags:

views:

15

answers:

2

hi, i m not able to modify table in SQL server. i m new to databases.

use work 
go 
alter table employee 
modify id varchar(20) 

error message is-

Msg 102, Level 15, State 1, Line 1 
Incorrect syntax near 'modify'

here is an screenshot

thanks

+1  A: 

The syntax should be

ALTER TABLE Employee ALTER COLUMN ID VarChar (20)

Here is the ALTER COLUMN syntax.

http://msdn.microsoft.com/en-us/library/ms190273.aspx

Now, having said all that, I have a question for you.. Why is your ID column a VarChar as opposed to an Identity Column?

Raj More
It could be that ID is like a UserID. Benefit of the doubt...
Joe
thanks raj more... still same problem[link](http://img219.imageshack.us/img219/1329/sqq.jpg)
Jaspal
@Joe I assumed just as much, but asked anyway thinking it may be a design time issue that we can correct before it gets out of hand for @Jaspal
Raj More
@Jaspal: Replace `MODIFY COLUMN` with `ALTER COLUMN`
Raj More
it worked raj...thanks:)
Jaspal
alter table table_name alter column column_name data_type this worked...thanks raj n AdaTheDev id is not identity raj. just a name "alter table table_name modify column_name data_type"--this worked fine on my college comp.. but gave error on my pc.. any idea why?
Jaspal
i m just practicing thats why id is varchar:)
Jaspal
the `alter table .. modify column ..` is an ORACLE syntax. sql server uses `alter table .. alter column ..`
Raj More
+2  A: 

You have the syntax for altering a table wrong. You need:

ALTER TABLE YourTable
ALTER COLUMN ExistingColumn VARCHAR(20)
AdaTheDev
alter table table_name alter column column_name data_type<br>this worked...thanks raj n AdaTheDev<br>id is not identity raj. just a namealter table table_name modify column_name data_type<br>this worked fine on my college comp.. but gave error on my pc
Jaspal