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)
 Cannot sort a row of size ... which is greater t

Author  Topic 

Kristen
Test

22859 Posts

Posted - 2004-05-28 : 13:02:01
I'm trying to copy some data from one database to another. Identical table structure on both.

Server: Msg 1540, Level 16, State 1, Procedure dng_TR_SYS_HTML, Line 22
Cannot sort a row of size 8150, which is greater than the allowable maximum of 8094.

So its dying in the Trigger. But I don't have a SORT anywhere [I think!!], so something must be implicitly doing that.


CREATE TABLE DNG_SYS_HTML_HTMLContent
(
sys_html_zEditNo int NULL ,
sys_html_zCrDt datetime NULL
CONSTRAINT DF_DNG_SYS_HTML_zCrDt DEFAULT (getdate()),
sys_html_zCrUser varchar (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
sys_html_zUpDt datetime NULL
CONSTRAINT DF_DNG_SYS_HTML_zUpDt DEFAULT (getdate()),
sys_html_zUpUser varchar (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
sys_html_Kind varchar (4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
sys_html_Code varchar (30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
sys_html_Type varchar (4) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
sys_html_Sequence int NOT NULL
CONSTRAINT DF_DNG_SYS_HTML_Seq DEFAULT (1),
sys_html_Lang varchar (2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
CONSTRAINT DF_DNG_SYS_HTML_Lang DEFAULT ('GB'),
sys_html_Text varchar (7900) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
sys_html_ID int IDENTITY (10000, 1) NOT NULL ,
CONSTRAINT PK_DNG_SYS_HTML_HTMLContent PRIMARY KEY CLUSTERED
(
sys_html_ID
) WITH FILLFACTOR = 90 ON PRIMARY ,
CONSTRAINT FK_DNG_SYS_HTML_HTMLContent_DNG_SYS_LANG_Language FOREIGN KEY
(
sys_html_Lang
) REFERENCES DNG_SYS_LANG_Language (
sys_lang_Code
)
) ON PRIMARY

Here's the code that UPDATEs the DESTINATION table based on the SOURCE table:

UPDATE D
SET
[sys_html_zEditNo] = S.[sys_html_zEditNo],
[sys_html_zCrDt] = S.[sys_html_zCrDt],
[sys_html_zCrUser] = S.[sys_html_zCrUser],
[sys_html_zUpDt] = S.[sys_html_zUpDt],
[sys_html_zUpUser] = S.[sys_html_zUpUser],
[sys_html_Kind] = S.[sys_html_Kind],
[sys_html_Code] = S.[sys_html_Code],
[sys_html_Type] = S.[sys_html_Type],
[sys_html_Sequence] = S.[sys_html_Sequence],
[sys_html_Lang] = S.[sys_html_Lang],
[sys_html_Text] = S.[sys_html_Text]
FROM RAPID_DEV.dbo.[DNG_SYS_HTML_HTMLContent] D
join RAPID_RK_040528_TEMP.dbo.[DNG_SYS_HTML_HTMLContent] S
ON D.[sys_html_ID] = S.[sys_html_ID]
WHERE
(
(D.[sys_html_Kind] <> S.[sys_html_Kind]
OR (D.[sys_html_Kind] IS NULL AND S.[sys_html_Kind] IS NOT NULL)
OR (D.[sys_html_Kind] IS NOT NULL AND S.[sys_html_Kind] IS NULL))
OR (D.[sys_html_Code] <> S.[sys_html_Code]
OR (D.[sys_html_Code] IS NULL AND S.[sys_html_Code] IS NOT NULL)
OR (D.[sys_html_Code] IS NOT NULL AND S.[sys_html_Code] IS NULL))
OR (D.[sys_html_Type] <> S.[sys_html_Type]
OR (D.[sys_html_Type] IS NULL AND S.[sys_html_Type] IS NOT NULL)
OR (D.[sys_html_Type] IS NOT NULL AND S.[sys_html_Type] IS NULL))
OR (D.[sys_html_Sequence] <> S.[sys_html_Sequence]
OR (D.[sys_html_Sequence] IS NULL AND S.[sys_html_Sequence] IS NOT NULL)
OR (D.[sys_html_Sequence] IS NOT NULL AND S.[sys_html_Sequence] IS NULL))
OR (D.[sys_html_Lang] <> S.[sys_html_Lang]
OR (D.[sys_html_Lang] IS NULL AND S.[sys_html_Lang] IS NOT NULL)
OR (D.[sys_html_Lang] IS NOT NULL AND S.[sys_html_Lang] IS NULL))
OR (D.[sys_html_Text] <> S.[sys_html_Text]
OR (D.[sys_html_Text] IS NULL AND S.[sys_html_Text] IS NOT NULL)
OR (D.[sys_html_Text] IS NOT NULL AND S.[sys_html_Text] IS NULL))
)

I tried adding OPTION (ROBUST PLAN) which generated:
Warning: The query processor could not produce a query plan from the optimizer because the total length of all the columns in the GROUP BY or ORDER BY clause exceeds 8000 bytes. Resubmit your query without the ROBUST PLAN hint.

WHAT GroupBy/OrderBy?????

The trigger is:

CREATE TRIGGER dbo.dng_TR_SYS_HTML
ON dbo.DNG_SYS_HTML_HTMLContent
AFTER INSERT, UPDATE, DELETE
AS
SET NOCOUNT ON
SET XACT_ABORT ON

DECLARE @dtNow datetime,
@strUser varchar(4)

SELECT @dtNow = GetDate(),
@strUser = left(user_name(), 4)

UPDATE U
SET
-- Set varchar columns to NULL if they are BLANK
[sys_html_Kind] = CASE WHEN I.sys_html_Kind = '' THEN NULL ELSE I.sys_html_Kind END,
[sys_html_Code] = CASE WHEN I.sys_html_Code = '' THEN NULL ELSE I.sys_html_Code END,
[sys_html_Type] = CASE WHEN I.sys_html_Type = '' THEN NULL ELSE I.sys_html_Type END,
[sys_html_Lang] = CASE WHEN I.sys_html_Lang = '' THEN NULL ELSE I.sys_html_Lang END,
[sys_html_Text] = CASE WHEN I.sys_html_Text = '' THEN NULL ELSE I.sys_html_Text END,

-- Set Edit Number, Create/Update dates and users
[sys_html_zEditNo] = COALESCE(I.sys_html_zEditNo, 0) + 1, -- Increment edit counter
[sys_html_zCrDt] = COALESCE(I.sys_html_zCrDt, @dtNow),
[sys_html_zCrUser] = COALESCE(I.sys_html_zCrUser, @strUser),
[sys_html_zUpDt] = COALESCE(I.sys_html_zUpDt, @dtNow),
[sys_html_zUpUser] = COALESCE(I.sys_html_zUpUser, @strUser)

FROM inserted I
JOIN dbo.DNG_SYS_HTML_HTMLContent U
ON U.sys_html_Kind = I.sys_html_Kind
AND U.sys_html_Code = I.sys_html_Code
AND U.sys_html_Type = I.sys_html_Type
AND U.sys_html_Sequence = I.sys_html_Sequence
AND U.sys_html_Lang = I.sys_html_Lang

-- AUDIT:Store any previous version (including where record is being deleted)
INSERT dbo.DNGa_SYS_HTML_HTMLContent
SELECT CASE WHEN I.sys_html_ID IS NULL THEN 'D' ELSE 'U' END, @dtNow, D.*
FROM deleted D
LEFT OUTER JOIN inserted I
ON I.sys_html_Kind = D.sys_html_Kind
AND I.sys_html_Code = D.sys_html_Code
AND I.sys_html_Type = D.sys_html_Type
AND I.sys_html_Sequence = D.sys_html_Sequence
AND I.sys_html_Lang = D.sys_html_Lang

GO

sorengi
Starting Member

48 Posts

Posted - 2004-05-28 : 15:33:49
This is a data issue. You have a row(s) in your table with more than the maximum allowable of 8094 bytes. You need to remove the records, or shorten some of the columns to that is does not exceed the max.

In the long run, you should change your table definition to not allow such a row to exists. (Shorten column lengths or break up the table.)

Michael D.

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-05-29 : 00:05:13
quote:
Originally posted by sorengi

This is a data issue. You have a row(s) in your table with more than the maximum allowable of 8094 bytes. You need to remove the records, or shorten some of the columns to that is does not exceed the max.

In the long run, you should change your table definition to not allow such a row to exists. (Shorten column lengths or break up the table.)

Sorry, but I don't see how it can be.

1) If I had created a table with more than the possible maximum I would have got the message:
quote:

Warning: The table 'DNG_SYS_HTML_HTMLContent' has been created but its maximum row size (nnnn) 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.


but I don't.

2) The data is coming from an identical table - so it must fit!

Kristen

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-06-03 : 11:18:52
Anyone have any thoughts on this?

I got around it by doing a SET ROWCOUNT 1 and looping round until it had transfered all the rows, but its happened again since and I'd like to get to the bottom of it.

I just can't fathom where the "SORT" part of the error message is coming from

Kristen
Go to Top of Page
   

- Advertisement -