Quote:
Originally Posted by seananderson
ALTER TABLE TEST2 RENAME NEWFIELD2 TO NEWCOLUMN
I am trying to rename a column in a query, but it fails wth the following error:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'NEWFIELD2'.
I also noted that in SQL Query Analyzer that the colour coding of the query indicates that RENAME isn't a correct command (ie: not shown in blue)
I also had the same problem when I tried to rename a whole table.
Any advice?
Regards,
Sean Anderson
|
to rename
for eg chenge column name for fnmae to fname in table employee
step 1 rename employee to employe
step 2 create table employee (fname,lname , and other columns of table) as select * from employe.
then drop employe
and add constraints againn to employee if any exist.
alter table do not change name of column , table and size of column if table data exist