SQL Server snippets
How to rename a column of a table
Example 1
Let's assume we have a #Schools
table and we want to RENAME the Name
column to Sign
column.
CREATE TABLE Schools(
[Name] varchar(250),
[Grade] varchar(150),
[City] varchar(150));
INSERT INTO
Schools([Name],[Grade],[City])
VALUES
('Astro School', 'Specialization school', 'Huston'),
('The white beach school', 'High School', 'Honolulu'),
('Queen High School', 'High School', 'London');
EXEC sp_RENAME 'Schools.Name' , 'Sign', 'COLUMN'
You can find an interactive version of this example following this link .