Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 ALTER TABLE problem with rowsize

Author  Topic 

anik5
Starting Member

6 Posts

Posted - 2006-06-20 : 11:48:27
The following script is giving an error BUT NOT ALWAYS:


Warning: The table '#tmp1' has been created but its maximum row size (9423) exceeds the maximum number of bytes per row (8060). INSERT or UPDATE of a row in this table will fail if the resulting row length exceeds 8060 bytes.

There has never been error on #tmp2

Both tables are EXACTLY the same.

Any suggestions? Is this a problem with ALTER TABLE? The total row size is less than 5000 including the unicode nvarchar

Thanks for suggestions.


drop table #tmp1
drop table #tmp2

create table #tmp1 (
f5 uniqueidentifier,
f1 nvarchar(50),
f2 nvarchar(200),
f10 int,
f11 int)

alter table #tmp1 add
[f6] [uniqueidentifier] ,
[f8] [uniqueidentifier] ,
[f3] [nvarchar] (2000) ,
[f4] [nvarchar] (200) ,
[f9] [bit]


create table #tmp2 (
f5 uniqueidentifier,
f1 nvarchar(50),
f2 nvarchar(200),
f10 int,
f11 int,
[f6] [uniqueidentifier] ,
[f8] [uniqueidentifier] ,
[f3] [nvarchar] (2000) ,
[f4] [nvarchar] (200) ,
[f9] [bit]
)

nr
SQLTeam MVY

12543 Posts

Posted - 2006-06-20 : 12:06:30
see
http://www.nigelrivett.net/SQLAdmin/AlterTableProblems.html

It explains why alter table can cause a lot of wasted space in a row and shows how to see where space is wasted.

Note what you have isn't an error it's a warning saying that the table you created has the possibility of a too long row. You won't get an error unless the data inserted causes a too long row.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

anik5
Starting Member

6 Posts

Posted - 2006-06-20 : 12:17:59
Thanks for the excellent link.

I understand the error is not really an error - just a warning.

Go to Top of Page
   

- Advertisement -