Search code examples
sqlsql-server

How can I alter column name in Sql server


I've a table Amount, having a column name amount_id which i want to change and update into account_id

I am using sp_rename function but i dont know how exactly i can change it

EXEC sp_rename 'Amount.Amount_id', 'Account_id', 'COLUMN';

This is the error given

Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong.


Solution

  • You are using the syntax to rename a table. For rename a column you need

      EXEC sp_rename '<Schema>.<Table>.<Fieldname>, 'newfield', 'COLUMN';