Jaspal
Jaspal

Reputation: 93

sql server modify error

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

Upvotes: 1

Views: 7297

Answers (2)

AdaTheDev
AdaTheDev

Reputation: 147224

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

ALTER TABLE YourTable
ALTER COLUMN ExistingColumn VARCHAR(20)

Upvotes: 6

Raj More
Raj More

Reputation: 48016

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?

Upvotes: 1

Related Questions