How to rename a column in a database table using SQL

0 votes
If I want to rename a column in an SQL database using SQL without changing any datatype, how should I proceed?

Is it possible to do the same, if yes please give me a solution. It is regarding any database in SQL Server.
Feb 9, 2022 in Database by Vaani
• 7,060 points
549 views

1 answer to this question.

0 votes

For SQL Server, use sp_rename

USE AdventureWorks;
GO
EXEC sp_rename 'Customers.CustomerTerritory.TerritoryID', 'TerrID', 'COLUMN';
GO

If you need to know more about SQL, it is recommended to go for the SQL Certification today.

answered Feb 9, 2022 by Neha
• 9,060 points

Related Questions In Database

0 votes
2 answers

How to select the nth row in a SQL database table?

SELECT * FROM ( SELECT ID, NAME, ROW_NUMBER() ...READ MORE

answered Apr 23, 2020 in Database by anand
• 140 points
25,151 views
0 votes
0 answers

How to rename a table in SQL Server?

The SQL query that I have used is : ALTER ...READ MORE

Sep 5, 2022 in Database by Kithuzzz
• 38,010 points
582 views
0 votes
0 answers

How to change column datatype in SQL database without losing data?

I have a SQL Server database, and ...READ MORE

Feb 25, 2022 in Database by Vaani
• 7,060 points
535 views
0 votes
0 answers

How to find sum of multiple columns in a table in SQL Server 2005?

I have a table Emp which has these rows: Emp_cd ...READ MORE

Aug 19, 2022 in Database by Kithuzzz
• 38,010 points
1,378 views
0 votes
1 answer

How Can I use "Date" Datatype in sql server?

There's problem in all of them and ...READ MORE

answered Feb 9, 2022 in Database by Neha
• 9,060 points
1,072 views
0 votes
1 answer

How Can I use "Date" Datatype in sql server?

Your dates are interpreted as MM-DD-YYYY. This ...READ MORE

answered Jun 21, 2022 in Others by nisha
• 2,210 points
354 views
0 votes
0 answers

How do I list all the columns in a table?

For the various popular database systems, how ...READ MORE

Aug 9, 2022 in Database by Kithuzzz
• 38,010 points
333 views
0 votes
0 answers

Reset identity seed after deleting records in SQL Server

A SQL Server database table has had ...READ MORE

Aug 22, 2022 in Database by Kithuzzz
• 38,010 points
464 views
0 votes
1 answer

How to drop all tables from a database with one SQL query?

Use the INFORMATION_SCHEMA.TABLES view to get the ...READ MORE

answered Feb 4, 2022 in Database by Neha
• 9,060 points
8,436 views
0 votes
1 answer

How to Insert date value in SQL table

Always use ANSI default string literal format for date i.e. YYYY-MM-DD like below. INSERT ...READ MORE

answered Feb 17, 2022 in Database by Neha
• 9,060 points
165,063 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