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 in Database by Vaani
• 7,020 points
139 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
answered Feb 9 by Neha
• 8,940 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
18,835 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 in Database by Kithuzzz
• 20,660 points
100 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 in Database by Vaani
• 7,020 points
123 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 in Database by Kithuzzz
• 20,660 points
453 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 in Database by Neha
• 8,940 points
262 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 in Others by nisha
• 2,190 points
76 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 in Database by Kithuzzz
• 20,660 points
42 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 in Database by Kithuzzz
• 20,660 points
46 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 in Database by Neha
• 8,940 points
1,063 views
0 votes
1 answer

How to generate the statement CREATE TABLE for an existing table in postgreSQL?

Generate table creation statement for an existing ...READ MORE

answered Feb 9 in Database by Neha
• 8,940 points
1,433 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