I am using SQL Server 2008 and Navicat. I need to rename a column in a table using SQL.
ALTER TABLE table_name RENAME COLUMN previous_name to new_name;
This statement doesn't work.
EXEC sp_RENAME 'TableName.PreviousColumnName' , 'NewColumnName', 'COLUMN'
See: SQL SERVER – How to Rename a Column Name or Table Name
Documentation: sp_rename (Transact-SQL)
For your case it would be:
EXEC sp_RENAME 'table_name.previous_name', 'new_name', 'COLUMN'
Don't forget to use single quotes to enclose your values.
The "indexes and keys" dialogue, not the ...READ MORE
For SQL Server, use sp_rename
EXEC sp_rename 'Customers.CustomerTerritory.TerritoryID', ...READ MORE
To hone my Linq-fu , I'm looking ...READ MORE
I am in the process of changing ...READ MORE
With 200 records currently, I want to ...READ MORE
How do I query the DateTime database ...READ MORE
I require the minutes-based time difference between ...READ MORE
I only need to choose the given ...READ MORE
MERGE INTO YourTable T
USING ...READ MORE
You can use the PIVOT function to ...READ MORE
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.