<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/">
  <channel>
    <title>Updating Large Value Data Types in SQL Server 2005</title>
    <link>http://blogs.lotterypost.com/speednet/2007/7/updating-large-value-data-types-in-sql-server.htm</link>
    <atom:link href="http://www.lotterypost.com/rss/blogcomments/18074" rel="self" type="application/rss+xml" />
    <description>Speednet's Blog: Updating Large Value Data Types in SQL Server 2005</description>
    <dc:language>en-us</dc:language>
    <generator>Lottery Post RSS Generator</generator>
    <item>
      <title>Original Blog Entry: Updating Large Value Data Types in SQL Server 2005</title>
      <link>http://blogs.lotterypost.com/speednet/2007/7/updating-large-value-data-types-in-sql-server.htm</link>
      <guid isPermaLink="true">http://blogs.lotterypost.com/speednet/2007/7/updating-large-value-data-types-in-sql-server.htm</guid>
      <pubDate>Fri, 20 Jul 2007 23:33:23 GMT</pubDate>
      <dc:creator>Speednet</dc:creator>
      <description><![CDATA[<p>SQL Server 2005 added some new <em>large value data types</em> that are extremely useful for storing large chunks of text.</p><p>Such is the case with any large forum web site, such as Lottery Post.&nbsp; Each forum post &mdash; whether humongous or a couple of words &mdash; occupies just one row [record] in the database.&nbsp; In fact, the entire content of&nbsp;a forum post is contained within just one cell [field].</p><p>The Lottery Post database was formerly stored using SQL Server 2000, before it was upgraded to SQL Server 2005 in November 2005.&nbsp; At the time, the only way to store the forum posts was using a <span style="font-family: courier new,courier">text</span> data type, which was fairly inefficient.</p><p>A <span style="font-family: courier new,courier">text</span> data type stores all of its data &mdash; for&nbsp;the one column &mdash; in an external text file, and each row in the data table contains a pointer into the text file, to where the data for each row is stored.&nbsp; Using that model, the performance of data updates can be handicapped by all the file I/O necessary to maintain the linkages and separate data files.</p><p>SQL Server 2005 introduced new data types for storing huge blocks of data: <span style="font-family: courier new,courier">varchar(MAX)</span>, <span style="font-family: courier new,courier">nvarchar(MAX)</span>, and <span style="font-family: courier new,courier">varbinary(MAX)</span>.&nbsp; Like the regular versions of these data types (using a number, 8,000 or less, to represent the maximum size instead of <span style="font-family: courier new,courier">MAX</span>), the new large value data types store the data in the data file itself, not an external file.&nbsp; Thus, the new data type are far more efficient.</p><p>It turns out there are additional benefits to these new large value data types as well.&nbsp; By accident, and because of my curiosity, I discovered that there have been modifications to the SQL&nbsp;<span style="font-family: courier new,courier">UPDATE</span> statement specifically for the new data types.</p><p>The new syntax allows the developer to modify a large value in the same way that the <span style="font-family: courier new,courier">STUFF()</span> function works.&nbsp; That is, it can insert a character string directly into the current value, and optionally replace the number of characters you specify.&nbsp; It's called a <em>partial update</em>.</p><p>This is a tremendous leap in efficienc....</p><p>[ <a href="http://blogs.lotterypost.com/speednet/2007/7/updating-large-value-data-types-in-sql-server.htm">More</a> ]</p>]]></description>
      <category>* Original Blog Entry</category>
      <wfw:comment>http://www.lotterypost.com/blogentry/18074</wfw:comment>
    </item>
  </channel>
</rss>
