<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Edwin M Sarmiento&gt;Spot the difference &#8211; SQL Server 2008 TSQL enhancements &#8211; Edwin M Sarmiento</title>
	<atom:link href="https://www.edwinmsarmiento.com/spot-the-difference-sql-server-2008-tsql-enhancements/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.edwinmsarmiento.com</link>
	<description>Intentional Excellence</description>
	<lastBuildDate>Mon, 13 Apr 2026 21:00:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
<site xmlns="com-wordpress:feed-additions:1">84283043</site>		<item>
		<title>&gt;Spot the difference &#8211; SQL Server 2008 TSQL enhancements</title>
		<link>https://www.edwinmsarmiento.com/spot-the-difference-sql-server-2008-tsql-enhancements/</link>
		<comments>https://www.edwinmsarmiento.com/spot-the-difference-sql-server-2008-tsql-enhancements/#respond</comments>
		<pubDate>Mon, 08 Oct 2007 09:09:00 +0000</pubDate>
		<dc:creator>Edwin M Sarmiento</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">http://bassplayerdoc.wordpress.com/2007/10/08/spot-the-difference-sql-server-2008-tsql-enhancements</guid>

				<description><![CDATA[&#62;If you&#8217;ve had your hands on T-SQL for quite some time, it wouldn&#8217;t be hard for you to identify the new enhancements available in SQL Server 2008. Now just for fun, try to identify what&#8217;s unusual in this script, from a SQL Server 2000/2005 point-of-view: DECLARE @variable int = 1;SET @variable += 1;CREATE TABLE table1 [&#8230;]]]></description>
					<content:encoded><![CDATA[<p>&gt;<span style="font-family:arial;">If you&#8217;ve had your hands on T-SQL for quite some time, it wouldn&#8217;t be hard for you to identify the new enhancements available in <strong><span style="font-size:85%;">SQL Server 2008</span></strong>. Now just for fun, try to identify what&#8217;s unusual in this script, from a <strong><span style="font-size:85%;">SQL Server 2000/2005</span></strong> point-of-view:</span></p>
<p><span style="color:#0000ff;"></p>
<p><span style="font-family:lucida grande;font-size:85%;"><strong>DECLARE </strong></span></span></p>
<p><span style="font-family:lucida grande;"><span style="font-size:85%;"><strong>@variable <span style="color:#0000ff;">int</span> <span style="color:#808080;">=</span> 1<span style="color:#808080;">;</span></strong></span></span><span style="font-family:lucida grande;"><span style="font-size:85%;"><strong><span style="color:#0000ff;"><br />SET </span>@variable <span style="color:#808080;">+=</span> 1</strong></span></span><span style="font-family:lucida grande;font-size:85%;color:#808080;"><strong>;<br /></strong></span><span style="color:#0000ff;"><br /><span style="font-family:lucida grande;font-size:85%;"><strong>CREATE TABLE </strong></span></span><br /><span style="font-family:lucida grande;"><span style="font-size:85%;"><strong>table1 <span style="color:#808080;">(</span>col1 <span style="color:#0000ff;">int</span></strong></span></span><span style="font-family:lucida grande;font-size:85%;color:#808080;"><strong>);<br /></strong></span><span style="color:#0000ff;"><br /><span style="font-family:lucida grande;font-size:85%;"><strong>INSERT </strong></span></span><span style="font-family:lucida grande;font-size:85%;"><strong>table1<br /><span style="color:#0000ff;">VALUES</span> <span style="color:#808080;">(</span>@variable<span style="color:#808080;">),(</span>@variable<span style="color:#808080;">+</span>1</strong></span><span style="color:#808080;"><span style="font-family:lucida grande;font-size:85%;"><strong>);</strong></span><br /></span><span style="color:#808080;"></span></p>
<p><span style="color:#808080;"><span style="font-family:arial;color:#000000;">If you try to execute this script in <strong><span style="font-size:85%;">SQL Server 2005</span></strong>, you&#8217;ll get an error similar to the one below</span></p>
<p></span></p>
<div><strong><span style="font-size:85%;color:#990000;">Msg 139, Level 15, State 1, Line 0<br />Cannot assign a default value to a local variable.<br />Msg 137, Level 15, State 2, Line 8<br />Must declare the scalar variable &#8220;@variable&#8221;.</span></strong></div>
<div></div>
<div><strong><span style="font-size:85%;color:#990000;"></span></strong></div>
<div><strong><span style="color:#990000;"></span></strong></div>
<div><span style="font-family:arial;color:#000000;">Now you start thinking, what could be wring with the script? The answer: T-SQL enhancements in SQL Server 2008. First, The <strong><span style="font-size:85%;">DECLARE</span></strong> statement in the first line now has the capability to accommodate initialization of variables unlike before where it only does variable declaration and you need either a <strong><span style="font-size:85%;">SET</span></strong> or <strong><span style="font-size:85%;">SELECT</span></strong> statement to assign values to variables. This is something similar to what you do in .NET, particularly VB.NET (the language enhancement part, in this case) where you can declare and assign values to variables in a single line. You can still use the <strong><span style="font-size:85%;">SET</span></strong> statement to assign values to variables. Next is the <strong><span style="font-size:85%;">+=</span></strong> operator (<span style="font-size:85%;"><strong>-=</strong> </span>is also included). I&#8217;ve first encountered this in C++ (Java, C# and VB.NET also have these) where the expression is used to increment (or decrement) variable values. In this case, the value for the variable <strong><span style="font-family:lucida grande;font-size:85%;">@variable</span></strong> is set to 2 after the second line because of the <strong><span style="font-size:85%;">+=</span></strong> operator. The third item is the existence of multiple row predicates in the <strong><span style="font-size:85%;">VALUES</span></strong> clause. This also works for an <strong><span style="font-size:85%;">UPDATE</span></strong> statement. This means you can now make your <strong><span style="font-size:85%;">INSERT</span></strong> or <strong><span style="font-size:85%;">UPDATE</span></strong> statements shorter with fewer codes. Not that you couldn&#8217;t do these in previous versions but this simply means writing less code and getting more work done (although you might be in trouble as your boss might give you more work to do)</span></div>
<div><span style="font-family:Arial;"></span> </div>
<div><span style="font-family:Arial;">Check out my SQL Server 2008 videos at <a href="http://blogcastrepository.com/level5/sql2008/">BlogCastRepository.com</a></span></div>
<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/92377218009570869-1074795481086866210?l=bassplayerdoc.blogspot.com' alt='' /></div>
]]></content:encoded>
			

		<wfw:commentRss>https://www.edwinmsarmiento.com/spot-the-difference-sql-server-2008-tsql-enhancements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
				<post-id xmlns="com-wordpress:feed-additions:1">26</post-id>	</item>
	</channel>
</rss>