Example 1
Rename the fname column to first_name
After the rename, the column is accessible only by its new name first_name. The data (Alice, Bob), the VARCHAR(100) type, and all row values are preserved unchanged. On SQL Server, sp_rename prints a warning that objects referencing the column may need updating — this is expected and does not indicate failure.
CREATE TABLE employees (id INT, fname VARCHAR(100), salary INT);
INSERT INTO
employees
VALUES
(1, 'Alice', 90000),
(2, 'Bob', 75000);ALTER TABLE employees
RENAME COLUMN fname TO first_name;
SELECT
id,
first_name,
salary
FROM
employees
ORDER BY
id;| id | first_name | salary |
|---|---|---|
| 1 | Alice | 90000 |
| 2 | Bob | 75000 |
CREATE TABLE employees (id INT, fname VARCHAR(100), salary INT);
INSERT INTO
employees
VALUES
(1, 'Alice', 90000),
(2, 'Bob', 75000);EXEC sp_rename 'employees.fname',
'first_name',
'COLUMN';
SELECT
id,
first_name,
salary
FROM
employees
ORDER BY
id;| id | first_name | salary |
|---|---|---|
| 1 | Alice | 90000 |
| 2 | Bob | 75000 |
SQL Server uses sp_rename instead of ALTER TABLE … RENAME COLUMN. The resulting table structure and data are identical across all engines.