INSERT DATA SIZE MORE THAN 8000 IN A COLUMN IN SQL SERVER 2005 AND NOT MORE THAN 12000

CREATE TABLE HeavySize
(
[Size] VARCHAR(MAX)
)

SELECT * FROM HeavySize

ALTER TABLE dbo.HeavySize
ADD CONSTRAINT MAXIMUMLENGTH
CHECK ( DATALENGTH ( HeavySize.[Size] ) <= 12000 )

INSERT INTO HeavySize ( [Size] )
VALUES ( REPLICATE ( CAST(‘ITEM’ AS VARCHAR(MAX)) , 13000 ))

Output
__________________

Msg 547, Level 16, State 0, Line 1
The INSERT statement conflicted with the CHECK constraint "MAXIMUMLENGTH". The conflict occurred in database "Hrms",
table "dbo.HeavySize", column ‘Size’.
The statement has been terminated.

Pawan Kumar

Pawankkmr@hotmail.com

Advertisements