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?

Computer Science

ScanSolve AI Answer

Step-by-step solution

3 steps

The 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:

  1. Remove the BonusMonth column if it was partially added or added incorrectly.

    ALTER TABLE Employee DROP COLUMN BonusMonth;
    
  2. Add the BonusMonth column correctly, extracting only the month from HireDate.

    ALTER TABLE Employee ADD COLUMN BonusMonth INT AS (MONTH(HireDate)) STORED;
    
  3. Verify that the BonusMonth column was added successfully and check its data type.

    DESCRIBE Employee;
    

    This command will display the structure of the Employee table, including all column names, their data types, and other properties. You should see BonusMonth listed as an INT type.

Was this helpful?

Still stuck on this one?

Ask a follow-up, and the answer starts from this question.

Got a different question?Ask your own question