Rename column SQL Server 2008

0 votes

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.

Feb 23, 2022 in Database by Neha
• 8,940 points

edited Feb 23, 2022 by Neha 130 views

1 answer to this question.

0 votes

Use sp_rename

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.

answered Feb 23, 2022 by Vaani
• 7,020 points

Related Questions In Database

0 votes
1 answer

How can I create a unique constraint on my column (SQL Server 2008 R2)?

The "indexes and keys" dialogue, not the ...READ MORE

answered Sep 20, 2022 in Database by narikkadan
• 50,080 points
148 views
0 votes
1 answer

How to rename a column in a database table using SQL?

For SQL Server, use sp_rename USE AdventureWorks; GO EXEC sp_rename 'Customers.CustomerTerritory.TerritoryID', ...READ MORE

answered Feb 9, 2022 in Database by Neha
• 8,940 points
206 views
0 votes
0 answers

Where can I find the Northwind database for Microsoft SQL Server 2008

To hone my Linq-fu , I'm looking ...READ MORE

Aug 15, 2022 in Database by Kithuzzz
• 27,160 points
154 views
0 votes
0 answers

SQL Server: Invalid Column Name

I am in the process of changing ...READ MORE

Aug 19, 2022 in Database by Kithuzzz
• 27,160 points
490 views
0 votes
0 answers

How to update Identity Column in SQL Server?

With 200 records currently, I want to ...READ MORE

Aug 9, 2022 in Database by Kithuzzz
• 27,160 points
499 views
0 votes
0 answers

Simple DateTime sql query

How do I query the DateTime database ...READ MORE

Aug 12, 2022 in Database by Kithuzzz
• 27,160 points
105 views
0 votes
0 answers

Calculate time difference in minutes in SQL Server

I require the minutes-based time difference between ...READ MORE

Aug 13, 2022 in Database by Kithuzzz
• 27,160 points
431 views
0 votes
0 answers

How can I select the first day of a month in SQL?

I only need to choose the given ...READ MORE

Aug 14, 2022 in Database by Kithuzzz
• 27,160 points
104 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3, 2022 in Database by Vaani
• 7,020 points
217 views
0 votes
1 answer

Convert Rows to columns using 'Pivot' in SQL Server

You can use the PIVOT function to ...READ MORE

answered Feb 8, 2022 in Database by Vaani
• 7,020 points
420 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP