2

How to rename a column "foo" into "bar" in a table "mytable"? I tried:

Alter table mytable
Alter column foo bar;
Alter table mytable  change foo bar;
Alter table mytable rename column foo to bar;

But it didn't work.

Stepan
  • 1,391
  • 18
  • 40

2 Answers2

4

Just a reminder. Renaming columns is dangerous, because it might break scripts.

sp_rename 'MYDB.FOO', 'BAR', 'COLUMN'; 
Stepan
  • 1,391
  • 18
  • 40
1

If you are using SSMS, you can just right click and press "Rename"...

enter image description here

TJB
  • 787
  • 1
  • 8
  • 29