We read your photo as:
How to fix 'Out of range' error when adding a BonusMonth column to an Employee table using ALTER TABLE in SQL?
ScanSolve AI Answer
Step-by-step solution
3 stepsThe output Records: 10 Duplicates: 0 Warnings: 0 indicates that the ALTER TABLE command itself did not create any duplicate rows. The "Out of range" error means that the value you tried to put into the BonusMonth column (likely the full HireDate) was not a valid integer for that column.
To "start over" and correctly add the BonusMonth column, follow these steps:
Remove the
BonusMonthcolumn if it was partially added or added incorrectly.ALTER TABLE Employee DROP COLUMN BonusMonth;Add the
BonusMonthcolumn correctly, extracting only the month fromHireDate.ALTER TABLE Employee ADD COLUMN BonusMonth INT AS (MONTH(HireDate)) STORED;Verify that the
BonusMonthcolumn was added successfully and check its data type.DESCRIBE Employee;This command will display the structure of the
Employeetable, including all column names, their data types, and other properties. You should seeBonusMonthlisted as anINTtype.
Still stuck on this one?
Ask a follow-up, and the answer starts from this question.