In run Microsoft SQL Server 2014. Upon altering a table, I get a warning about the row size.
ALTER TABLE myTable
ALTER COLUMN aRandomColumn NVARCHAR(10);
Warning: The table "myTable" has been created, but its maximum row size exceeds the allowed maximum of 8060 bytes. INSERT or UPDATE to this table will fail if the resulting row exceeds the size limit.
The table has 75 columns:
- 13 date
- 9 bit
- 8 int
- 5 decimal(18,5)
- 4 bigint
- 3 money
- 19 nvarchar(10)
- 10 nvarchar(20)
- 1 nvarchar(30)
- 1 nvarchar(40)
- 2 nvarchar(50)
By my calculations, the nvarchars take up 1120 bytes, the other columns 121 (not sure but it won't be much more).
How does this exceed 8060 bytes? How can I get rid of this warning?
Tried to sum all columns with isnull(datalength(myColumnName), 1)
and the actual data never exceeds 600.
Found a similar question but change tracking is off for me, so it didn't help. Also cleantable, found in this question, didn't help.
However, when I copy the table, the new table does not produce this warning.
SELECT * INTO myNewTable FROM myTable;
-- (8561 row(s) affected)
ALTER TABLE myNewTable
ATLER COLUMN aRandomColumn NVARCHAR(10);
-- Command(s) completed successfully.