Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2017 July SQL Server: Practical example of Exceeding the maximum row size of 8060

SQL Server: Practical example of Exceeding the maximum row size of 8060

SQL Data OverFlow

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

I already have written a couple of articles on data overflow and data exceeding problem of SQL Server.
For theory – You can access below articles because, In this post, I am sharing the practical example.

SQL Server: What happened, when Row Overflow and Data Exceeding 8KB?

SQL Server: The Internal Structure of the Data Page

Execute below steps and understand the 8kb fundamentals of SQL Server:

Try to create a large table which exceeds 8055 bytes:

1
2
3
4
5
6
7
CREATE TABLE tbl_LargeTable
(
CharColumn1 CHAR(5000)
,CharColumn2 CHAR(3000)
,CharColumn3 CHAR(55)
)
GO

You will get a below error:

1
2
Msg 1701, Level 16, State 1, Line 1
Creating or altering table 'tbl_LargeTable' failed because the minimum row size would be 8062, including 7 bytes of internal overhead. This exceeds the maximum allowable table row size of 8060 bytes.

Now, try to create a large table by adding one varchar column:
I changed CharColumn3 CHAR(55) to CHAR(40), and added new Varchar column.
Here, you can create a table with the warning only because VARCHAR is variable type so if you try to add more data in VARCHAR which are crossing 8050 bytes, your insert or update will fail.

1
2
3
4
5
6
7
8
CREATE TABLE tbl_LargeTable
(
CharColumn1 CHAR(5000)
,CharColumn2 CHAR(3000)
,CharColumn3 CHAR(40)
,VarCollumn1 VARCHAR(1000)
)
GO

You will get a below warning:

1
Warning: The table "tbl_LargeTable" 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 Example of Successful INSERT:

1
2
3
4
5
6
7
8
INSERT INTO tbl_LargeTable
VALUES
(
REPLICATE('z', 5000),
REPLICATE('b', 3000),
REPLICATE('c', 40),
REPLICATE('a', 5)
)

The example of failed INSERT:

1
2
3
4
5
6
7
8
INSERT INTO tbl_LargeTable
VALUES
(
REPLICATE('z', 5000),
REPLICATE('b', 3000),
REPLICATE('c', 40),
REPLICATE('a', 10)
)

You will get below error:

1
2
3
Msg 511, Level 16, State 1, Line 1
Cannot create a row of size 8061 which is greater than the allowable maximum row size of 8060.
The statement has been terminated.

Jul 21, 2017Anvesh Patel
SQL Puzzle: SQL Advance Query - Find a Book name which is printed in 50% of LanguagesSQL Server: SSMS Client Statistics - more than STATISTICS IO

Leave a Reply Cancel reply

CAPTCHA
Refresh

*

Anvesh Patel
Anvesh Patel

Database Engineer

ImageJuly 21, 2017 SQL Server8 kb, Anvesh Patel, data exceeding, database, database research and development, dbrnd, ROW OVERFLOW, SQL Query, SQL Server, SQL Server Administrator, SQL Server Error, SQL Server Monitoring, SQL Server Performance Tuning, SQL Server Programming, SQL Server Tips and Tricks, TSQL
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....