<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Lenni Lobel on SQL Server and .NET Development</title>
	<atom:link href="http://lennilobel.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://lennilobel.wordpress.com</link>
	<description>SQL Server, data access and general .NET development</description>
	<lastBuildDate>Sun, 22 Jan 2012 18:56:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='lennilobel.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Lenni Lobel on SQL Server and .NET Development</title>
		<link>http://lennilobel.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://lennilobel.wordpress.com/osd.xml" title="Lenni Lobel on SQL Server and .NET Development" />
	<atom:link rel='hub' href='http://lennilobel.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Geospatial Support for Circular Data in SQL Server 2012</title>
		<link>http://lennilobel.wordpress.com/2012/01/22/geospatial-support-for-circular-data-in-sql-server-2012/</link>
		<comments>http://lennilobel.wordpress.com/2012/01/22/geospatial-support-for-circular-data-in-sql-server-2012/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 03:25:07 +0000</pubDate>
		<dc:creator>Leonard Lobel</dc:creator>
				<category><![CDATA[SQL Server 2012 Code-Named "Denali"]]></category>
		<category><![CDATA[SQL Server 2012 Circular Spatial Data]]></category>

		<guid isPermaLink="false">http://lennilobel.wordpress.com/?p=1154</guid>
		<description><![CDATA[SQL Server 2012 adds many significant improvements to the spatial support that was first introduced with SQL Server 2008. In this blog post, I&#8217;ll explore one of the more notable enhancements: support for curves and arcs (circular data). SQL Server 2008 only supported straight lines, or polygons composed of straight lines. The three new shapes in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=1154&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>SQL Server 2012 adds many significant improvements to the spatial support that was first introduced with SQL Server 2008. In this blog post, I&#8217;ll explore one of the more notable enhancements: support for curves and arcs (circular data). SQL Server 2008 only supported straight lines, or polygons composed of straight lines. The three new shapes in SQL Server 2012 are circular strings, compound curves, and curve polygons. All three are supported in Well-Known Text (WKT), Well-Known Binary (WKB), and Geometry Markup Language (GML) by both the <em>geometry</em> (planar, or &#8220;flat-earth&#8221; model) and <em>geography</em> (ellipsoidal sphere, or geodetic) data types, and all of the existing methods work on the new shapes.</p>
<h3>Circular Strings</h3>
<p>A circular string defines a basic curved line, similar to how a line string defines a straight line. It takes a minimum of three coordinates to define a circular string; the first and third coordinates define the end points of the line, and the second coordinate (the “anchor” point, which lies somewhere between the end points) determines the arc of the line. Here is the shape represented by <em>CIRCULARSTRING(0 1, .25 0, 0 -1):</em></p>
<p><a href="http://lennilobel.files.wordpress.com/2012/01/10x21.png"><img class="alignnone size-full wp-image-1157" title="10x21" src="http://lennilobel.files.wordpress.com/2012/01/10x21.png?w=780" alt=""   /></a></p>
<p>The following code produces four circular strings. All of them have the same start and end points, but different anchor points. The lines are buffered slightly to make them easier to see in the spatial viewer.</p>
<p><pre class="brush: plain;">-- Create a &quot;straight&quot; circular line
SELECT geometry::Parse('CIRCULARSTRING(0 8, 4 0, 8 -8)').STBuffer(.1)
UNION ALL  -- Curve it
SELECT geometry::Parse('CIRCULARSTRING(0 8, 4 4, 8 -8)').STBuffer(.1)
UNION ALL  -- Curve it some more
SELECT geometry::Parse('CIRCULARSTRING(0 8, 4 6, 8 -8)').STBuffer(.1)
UNION ALL  -- Curve it in the other direction
SELECT geometry::Parse('CIRCULARSTRING(0 8, 4 -6, 8 -8)').STBuffer(.1)</pre></p>
<p>The spatial viewer in SQL Server Management Studio shows the generated shapes:</p>
<p><a href="http://lennilobel.files.wordpress.com/2012/01/10x22.png"><img class="alignnone size-full wp-image-1158" title="10x22" src="http://lennilobel.files.wordpress.com/2012/01/10x22.png?w=780" alt=""   /></a></p>
<p>The first shape is a “straight circular” line, because the anchor point is position directly between the start and end points. The next two shapes use the same end points with the anchor out to the right (4), one a bit further than the other (6). The last shape also uses the same end points, but specifies an anchor point that curves the line to the left rather than the right (-6).</p>
<p>You can extend circular strings with as many curve segments as you want. Do this by defining another two coordinates for each additional segment. The last point of the previous curve serves as the first end point of the next curve segment, so the two additional coordinates respectively specify the next segment’s anchor and second end point. Thus, valid circular strings will always have an odd number of points. You can extend a circular string indefinitely to form curves and arcs of any kind.</p>
<p>It’s easy to form a perfect circle by connecting two semi-circle segments. For example, the following illustration shows the circle produced by <em>CIRCULARSTRING(0 4, 4 0, 8 4, 4 8, 0 4)</em>.</p>
<p><a href="http://lennilobel.files.wordpress.com/2012/01/circle.png"><img class="alignnone size-full wp-image-1163" title="Circle" src="http://lennilobel.files.wordpress.com/2012/01/circle.png?w=780" alt=""   /></a></p>
<p>This particular example connects the end of the second segment to the beginning of the first segment to form a closed shape. Note that this is certainly not required of circular strings (or line strings), and that closing the shape by connecting the last segment to the first still does not result in a polygon, which is a two dimensional shape that has area. Despite being closed, this circle is still considered a one-dimensional shape with no area. As you’ll soon see, the curve polygon can be used to convert closed line shapes into true polygons.</p>
<h3>Compound Curves</h3>
<p>A compound curve is a set of circular strings, or circular strings combined with line strings, that form a desired curved shape. The end point of each element in the collection must match the starting point of the following element, so that compound curves are defined in a “connect-the-dots” fashion. The following code produces a compound curve and compares it with the equivalent geometry collection shape.</p>
<p><pre class="brush: plain;">-- Compound curve
 DECLARE @CC geometry = '
  COMPOUNDCURVE(
   (4 4, 4 8),
   CIRCULARSTRING(4 8, 6 10, 8 8),
   (8 8, 8 4),
   CIRCULARSTRING(8 4, 2 3, 4 4)
  )'

-- Equivalent geometry collection
 DECLARE @GC geometry = '
  GEOMETRYCOLLECTION(
   LINESTRING(4 4, 4 8),
   CIRCULARSTRING(4 8, 6 10, 8 8),
   LINESTRING(8 8, 8 4),
   CIRCULARSTRING(8 4, 2 3, 4 4)
  )'

-- They both render the same shape in the spatial viewer
 SELECT @CC.STBuffer(.5)
 UNION ALL
 SELECT @GC.STBuffer(1.5)</pre></p>
<p>This code creates a keyhole shape using a compound curve, and also creates an identical shape as a geometry collection (though notice that the <em>LINESTRING</em> keyword is not—and cannot—be specified when defining a compound curve). It then buffers both of them with different padding, so that the spatial viewer clearly shows the two identical shapes on top of one another, as shown:</p>
<p><a href="http://lennilobel.files.wordpress.com/2012/01/compoundcurve.png"><img class="alignnone size-full wp-image-1164" title="CompoundCurve" src="http://lennilobel.files.wordpress.com/2012/01/compoundcurve.png?w=780" alt=""   /></a></p>
<p>Both the compound curve and the geometry collection yield identical shapes. In fact, the expression <em>@CC.STEquals(@GC)</em> which compares the two instances for equality returns 1 (for true). The <em>STEquals</em> method tests for “spatial equality,” meaning it returns true if two instances produce the same shape even if they are being rendered using different spatial data classes. Furthermore, recall that segments of a circular string can be made perfectly straight by positioning the anchor directly between the end points, meaning that the circular string offers yet a third option for producing the very same shape. So which one should you use? Comparing these spatial data classes will help you determine which one is best to use in different scenarios.</p>
<p>A geometry collection (which was already supported in SQL Server 2008) is the most accommodating, but carries the most storage overhead. Geometry collections can hold instances of any spatial data class, and the instances don’t need to be connected to (or intersected with) each other in any way. The collection simply holds a bunch of different shapes as a set, which in this example just happens to be several line strings and circular strings connected at their start and end points.</p>
<p>In contrast, the new compound curve class in SQL Server 2012 has the most constraints but is the most lightweight in terms of storage. It can <em>only</em> contain line strings or circular strings, and each segment’s start point must be connected to the previous segment’s end point (although it is most certainly <em>not</em> necessary to connect the first and last segments to form a closed shape as in this example). The <em>DATALENGTH</em> function shows the difference in storage requirements; <em>DATALENGTH(@CC)</em> returns 152 and <em>DATALENGTH(@GC)</em> returns 243. In our current example, <em>DATALENGTH(@CC)</em> returns 152 and <em>DATALENGTH(@GC)</em> returns 243. This means that the same shape requires 38% less storage space by using a compound curve instead of a geometry collection. A compound curve is also more storage-efficient than a multi-segment circular line string when straight lines are involved. This is because there is overhead for the mere potential of a curve, since the anchor point requires storage even when it’s position produces straight lines, whereas compound curves are optimized specifically to connect circular strings and (always straight) line strings.</p>
<h3>Curve Polygons</h3>
<p>A curve polygon is very similar to an ordinary polygon; like an ordinary polygon, a curve polygon specifies a “ring” that defines a closed shape, and can also specify additional inner rings to define “holes” inside the shape. The only fundamental difference between a polygon and a curve polygon is that the rings of a curve polygon can include circular shapes, whereas an ordinary polygon is composed exclusively with straight lines. Specifically, each ring in a curve polygon can consist of any combination of line strings, circular strings, and compound curves that collectively define the closed shape. For example, the following code produces a curve polygon with the same keyhole outline that I just demonstrated for the compound curve.</p>
<p><pre class="brush: plain;">-- Curve polygon
 SELECT geometry::Parse('
  CURVEPOLYGON(
   COMPOUNDCURVE(
    (4 4, 4 8),
    CIRCULARSTRING(4 8, 6 10, 8 8),
    (8 8, 8 4),
    CIRCULARSTRING(8 4, 2 3, 4 4)
   )
  )')</pre></p>
<p>This code has simply specified the same compound curve as the closed shape of a curve polygon. Although the shape is the same, the curve polygon is a two-dimensional object, whereas the compound curve version of the same shape is a one-dimensional object. This can be seen visually by the spatial viewer results, which shades the interior of the curve polygon as shown here:</p>
<p><a href="http://lennilobel.files.wordpress.com/2012/01/curvepolygon.png"><img class="alignnone size-full wp-image-1165" title="CurvePolygon" src="http://lennilobel.files.wordpress.com/2012/01/curvepolygon.png?w=780" alt=""   /></a></p>
<h3>Conclusion</h3>
<p>Circular data support is an important new capability added to the spatial support in SQL Server 2012. In this blog post, I demonstrated the three new spatial data classes for curves and arcs: circular strings, compound curves, and curve polygons. Stay tuned for my next post (coming soon), for more powerful and fun spatial enhancements coming soon in SQL Server 2012!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lennilobel.wordpress.com/1154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lennilobel.wordpress.com/1154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lennilobel.wordpress.com/1154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lennilobel.wordpress.com/1154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lennilobel.wordpress.com/1154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lennilobel.wordpress.com/1154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lennilobel.wordpress.com/1154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lennilobel.wordpress.com/1154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lennilobel.wordpress.com/1154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lennilobel.wordpress.com/1154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lennilobel.wordpress.com/1154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lennilobel.wordpress.com/1154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lennilobel.wordpress.com/1154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lennilobel.wordpress.com/1154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=1154&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lennilobel.wordpress.com/2012/01/22/geospatial-support-for-circular-data-in-sql-server-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e98e16e27fd8ae3e079834b881c74f72?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lennilobel</media:title>
		</media:content>

		<media:content url="http://lennilobel.files.wordpress.com/2012/01/10x21.png" medium="image">
			<media:title type="html">10x21</media:title>
		</media:content>

		<media:content url="http://lennilobel.files.wordpress.com/2012/01/10x22.png" medium="image">
			<media:title type="html">10x22</media:title>
		</media:content>

		<media:content url="http://lennilobel.files.wordpress.com/2012/01/circle.png" medium="image">
			<media:title type="html">Circle</media:title>
		</media:content>

		<media:content url="http://lennilobel.files.wordpress.com/2012/01/compoundcurve.png" medium="image">
			<media:title type="html">CompoundCurve</media:title>
		</media:content>

		<media:content url="http://lennilobel.files.wordpress.com/2012/01/curvepolygon.png" medium="image">
			<media:title type="html">CurvePolygon</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server 2012 Windowing Functions Part 2 of 2: New Analytic Functions</title>
		<link>http://lennilobel.wordpress.com/2012/01/03/sql-server-2012-windowing-functions-part-2-of-2-new-analytic-functions/</link>
		<comments>http://lennilobel.wordpress.com/2012/01/03/sql-server-2012-windowing-functions-part-2-of-2-new-analytic-functions/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 15:47:28 +0000</pubDate>
		<dc:creator>Leonard Lobel</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2012 Code-Named "Denali"]]></category>
		<category><![CDATA[CUME_DIST]]></category>
		<category><![CDATA[FIRST_VALUE]]></category>
		<category><![CDATA[LAG]]></category>
		<category><![CDATA[LAST_VALUE]]></category>
		<category><![CDATA[LEAD]]></category>
		<category><![CDATA[PERCENTILE_CONT]]></category>
		<category><![CDATA[PERCENTILE_DISC]]></category>
		<category><![CDATA[PERCENT_RANK]]></category>
		<category><![CDATA[SQL Server 2012 Analytic Windowing Functions]]></category>
		<category><![CDATA[T-SQL Analytic Functions]]></category>
		<category><![CDATA[T-SQL Analytic Windowing Functions]]></category>

		<guid isPermaLink="false">http://lennilobel.wordpress.com/?p=1112</guid>
		<description><![CDATA[This is the second half of my two-part article on windowing functions in SQL Server 2012. In Part 1, I explained the new running and sliding aggregation capabilities added to the OVER clause in SQL Server 2012. In this post, I&#8217;ll explain the new T-SQL analytic windowing functions. All of these functions operate using the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=1112&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is the second half of my two-part article on windowing functions in SQL Server 2012. In <a href="http://lennilobel.wordpress.com/2011/12/12/sql-server-2012-windowing-functions-part-1-of-2-running-and-sliding-aggregates/">Part 1</a>, I explained the new running and sliding aggregation capabilities added to the <em>OVER</em> clause in SQL Server 2012. In this post, I&#8217;ll explain the new T-SQL analytic windowing functions. All of these functions operate using the windowing principles I explained in <a href="http://lennilobel.wordpress.com/2011/12/12/sql-server-2012-windowing-functions-part-1-of-2-running-and-sliding-aggregates/">Part 1</a>.</p>
<h3>Eight New Analytic Functions</h3>
<p>There are eight new analytic functions that have been added to T-SQL. All of them work in conjunction with an ordered window defined with an associated <em>ORDER BY</em> clause that can be optionally partitioned with a <em>PARTITION BY</em> clause and framed with a <em>BETWEEN</em> clause. The new functions are:</p>
<p><em> • FIRST_VALUE</em><br />
<em> • LAST_VALUE</em><br />
<em> • LAG</em><br />
<em> • LEAD</em><br />
<em> • PERCENT_RANK</em><br />
<em> • CUME_DIST</em><br />
<em> • PERCENTILE_CONT</em><br />
<em> • PERCENTILE_DISC</em></p>
<p>In the following code listing, the <em>FIRST_VALUE</em>, <em>LAST_VALUE</em>, <em>LAG</em>, and <em>LEAD</em> functions are used to analyze a set of orders at the product level.</p>
<p><pre class="brush: plain;">DECLARE @Orders AS table(OrderDate date, ProductID int, Quantity int)
INSERT INTO @Orders VALUES
 ('2011-03-18', 142, 74),
 ('2011-04-11', 123, 95),
 ('2011-04-12', 101, 38),
 ('2011-05-21', 130, 12),
 ('2011-05-30', 101, 28),
 ('2011-07-25', 123, 57),
 ('2011-07-28', 101, 12)

SELECT
  OrderDate,
  ProductID,
  Quantity,
  WorstOn = FIRST_VALUE(OrderDate) OVER(PARTITION BY ProductID ORDER BY Quantity),
  BestOn = LAST_VALUE(OrderDate) OVER(PARTITION BY ProductID ORDER BY Quantity
                          ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
  PrevOn = LAG(OrderDate, 1) OVER(PARTITION BY ProductID ORDER BY OrderDate),
  NextOn = LEAD(OrderDate, 1) OVER(PARTITION BY ProductID ORDER BY OrderDate)
 FROM @Orders
 ORDER BY OrderDate

OrderDate   ProductID  Quantity  WorstOn     BestOn      PrevOn      NextOn
----------  ---------  --------  ----------  ----------  ----------  ----------
2011-03-18  142        74        2011-03-18  2011-03-18  NULL        NULL
2011-04-11  123        95        2011-07-25  2011-04-11  NULL        2011-07-25
2011-04-12  101        38        2011-07-28  2011-04-12  NULL        2011-05-30
2011-05-21  130        12        2011-05-21  2011-05-21  NULL        NULL
2011-05-30  101        28        2011-07-28  2011-04-12  2011-04-12  2011-07-28
2011-07-25  123        57        2011-07-25  2011-04-11  2011-04-11  NULL
2011-07-28  101        12        2011-07-28  2011-04-12  2011-05-30  NULL</pre></p>
<p>In this query, four analytic functions specify an <em>OVER</em> clause that partitions the result set by <em>ProductID</em>. The product partitions defined for <em>FIRST_VALUE</em> and <em>LAST_VALUE</em> are sorted by <em>Quantity</em>, while the product partitions for <em>LAG</em> and <em>LEAD</em> are sorted by <em>OrderDate</em>. The full result set is sorted by <em>OrderDate</em>, so you need to visualize the sorted partition for each of the four functions to understand the output—the result set sequence is not the same as the row sequence used in the windowing functions.</p>
<h3><em>FIRST_VALUE</em> and <em>LAST_VALUE</em></h3>
<p>The <em>WorstOn</em> and <em>BestOn</em> columns use <em>FIRST_VALUE</em> and <em>LAST_VALUE</em> respectively to return the “worst” and “best” dates for the product in each partition. Performance is measured by quantity, so sorting each product’s partition by quantity will position the worst order at the first row in the partition and the best order at the last row in the partition. <em>FIRST_VALUE</em> and <em>LAST_VALUE</em> can return the value of any column (<em>OrderDate</em>, in this case), not just the aggregate column itself. For <em>LAST_VALUE</em>, it is also necessary to explicitly define a window over the entire partition with <em>ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING</em>. Otherwise, as explained in my coverage of <em>OVER</em> clause enhancements in <a href="http://lennilobel.wordpress.com/2011/12/12/sql-server-2012-windowing-functions-part-1-of-2-running-and-sliding-aggregates/">Part 1</a>, the default window is <em>ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW</em>, which frames (constrains) the window, and does not consider the remaining rows in the partition that are needed to obtain the highest quantity for <em>LAST_VALUE</em>.</p>
<p>In the output, notice that <em>OrderDate</em>, <em>LowestOn</em>, and <em>HighestOn</em> for the first order (product 142) are all the same value (3/18). This is because product 142 was only ordered once, so <em>FIRST_VALUE</em> and <em>LAST_VALUE</em> operate over a partition that has only this one row in it, with an <em>OrderDate</em> value of 3/18. The second row is for product 123, quantity 95, ordered on 4/11. Four rows ahead in the result set (not the partition) there is another order for product 123, quantity 57, placed on 7/25. This means that, for this product, <em>FIRST_VALUE</em> and <em>LAST_VALUE</em> operate over a partition that has these two rows in it, sorted by quantity. This positions the 7/25 order (quantity 57) first and the 4/11 (quantity 95) last within the partition. As a result, rows for product 123 report 7/25 for <em>WorstDate</em> and 4/11 for <em>BestDate</em>. The next order (product 101) appears two more times in the result set, creating a partition of three rows. Again, based on the <em>Quantity</em> sort of the partition, each row in the partition reports the product’s worst and best dates (which are 7/28 and 4/12, respectively).</p>
<h3><em>LAG</em> and <em>LEAD</em></h3>
<p>The <em>PrevOn</em> and <em>NextOn</em> columns use <em>LAG</em> and <em>LEAD</em> to return the previous and next date that each product was ordered. They specify an <em>OVER</em> clause that partitions by <em>ProductId</em> as before, but the rows in these partitions are sorted by <em>OrderDate</em>. Thus, the <em>LAG</em> and <em>LEAD</em> functions examine each product’s orders in chronological sequence, regardless of quantity. For each row in each partition, <em>LAG</em> is able to access previous (lagging) rows within the same partition. Similarly, <em>LEAD</em> can access subsequent (leading) rows within the same partition. The first parameter to <em>LAG</em> and <em>LEAD</em> specifies the column value to be returned from a lagging or leading row, respectively. The second parameter specifies the number of rows back or forward <em>LAG</em> and <em>LEAD</em> should seek within each partition, relative to the current row. The query passes <em>OrderDate</em> and <em>1</em> as parameters to <em>LAG</em> and <em>LEAD</em>, using product partitions that are ordered by date. Thus, the query returns the most recent past date, and nearest future date, that each product was ordered.</p>
<p>Because the first order’s product (142) was only ordered once, its single-row partition has no lagging or leading rows, and so <em>LAG</em> and <em>LEAD</em> both return <em>NULL</em> for <em>PrevOn</em> and <em>NextOn</em>. The second order (on 4/11) is for product 123, which was ordered again on 7/25, creating a partition with two rows sorted by <em>OrderDate</em>, with the 4/11 order positioned first and the 7/25 order positioned last within the partition. The first row in a multi-row window has no lagging rows, but at least one leading row. Similarly, the last order in a multi-row window has at least one lagging row, but no leading rows. As a result, the first order (4/11) reports <em>NULL</em> and 7/25 for <em>PrevOn</em> and <em>NextOn</em> (respectively), and the second order (7/25) reports 4/11 and <em>NULL</em> for <em>PrevOn</em> and <em>NextOn</em> (respectively). Product 101 was ordered three times, which creates a partition of three rows. In this partition, the second row has both a lagging row and a leading row. Thus, the three orders report <em>PrevOn</em> and <em>NextOn</em> values for product 101, respectively indicating <em>NULL</em>-5/30 for the first (4/12) order, 4/12-7/28 for the second (5/30) order, and 5/30-<em>NULL</em> for the third and last order.</p>
<p>The last functions to examine are <em>PERCENT_RANK</em> (rank distribution), <em>CUME_DIST</em> (cumulative distribution, or percentile), PERCENTILE_CONT (continuous percentile lookup), and PERCENTILE_DISC (discreet percentile lookup). The following queries demonstrate these functions, which are all closely related, by querying sales figures across each quarter of two years.</p>
<p><pre class="brush: plain;">DECLARE @Sales table(Yr int, Qtr int, Amount money)
INSERT INTO @Sales VALUES
  (2010, 1, 5000), (2010, 2, 6000), (2010, 3, 7000), (2010, 4, 2000),
  (2011, 1, 1000), (2011, 2, 2000), (2011, 3, 3000), (2011, 4, 4000)

-- Distributed across all 8 quarters
SELECT
  Yr, Qtr, Amount,
  R = RANK() OVER(ORDER BY Amount),
  PR = PERCENT_RANK() OVER(ORDER BY Amount),
  CD = CUME_DIST() OVER(ORDER BY Amount)
 FROM @Sales
 ORDER BY Amount

-- Distributed (partitioned) by year with percentile lookups
SELECT
  Yr, Qtr, Amount,
  R = RANK() OVER(PARTITION BY Yr ORDER BY Amount),
  PR = PERCENT_RANK() OVER(PARTITION BY Yr ORDER BY Amount),
  CD = CUME_DIST() OVER(PARTITION BY Yr ORDER BY Amount),
  PD5 = PERCENTILE_DISC(.5) WITHIN GROUP (ORDER BY Amount) OVER(PARTITION BY Yr),
  PD6 = PERCENTILE_DISC(.6) WITHIN GROUP (ORDER BY Amount) OVER(PARTITION BY Yr),
  PC5 = PERCENTILE_CONT(.5) WITHIN GROUP (ORDER BY Amount) OVER(PARTITION BY Yr),
  PC6 = PERCENTILE_CONT(.6) WITHIN GROUP (ORDER BY Amount) OVER(PARTITION BY Yr)
 FROM @Sales
 ORDER BY Yr, Amount

Yr    Qtr  Amount   R  PR                 CD
----  ---  -------  -  -----------------  -----
2011  1    1000.00  1  0                  0.125
2011  2    2000.00  2  0.142857142857143  0.375
2010  4    2000.00  2  0.142857142857143  0.375
2011  3    3000.00  4  0.428571428571429  0.5
2011  4    4000.00  5  0.571428571428571  0.625
2010  1    5000.00  6  0.714285714285714  0.75
2010  2    6000.00  7  0.857142857142857  0.875
2010  3    7000.00  8  1                  1

Yr    Qtr  Amount   R  PR                 CD    PD5      PD6      PC5   PC6
----  ---  -------  -  -----------------  ----  -------  -------  ----  ----
2010  4    2000.00  1  0                  0.25  5000.00  6000.00  5500  5800
2010  1    5000.00  2  0.333333333333333  0.5   5000.00  6000.00  5500  5800
2010  2    6000.00  3  0.666666666666667  0.75  5000.00  6000.00  5500  5800
2010  3    7000.00  4  1                  1     5000.00  6000.00  5500  5800
2011  1    1000.00  1  0                  0.25  2000.00  3000.00  2500  2800
2011  2    2000.00  2  0.333333333333333  0.5   2000.00  3000.00  2500  2800
2011  3    3000.00  3  0.666666666666667  0.75  2000.00  3000.00  2500  2800
2011  4    4000.00  4  1                  1     2000.00  3000.00  2500  2800</pre></p>
<p>The new functions are all based on the <em>RANK</em> function introduced in SQL Server 2005. So both these queries also report on <em>RANK</em>, which will aid both in my explanation and your understanding of each of the new functions.</p>
<h3><em>PERCENT_RANK</em> and <em>CUME_DIST</em></h3>
<p>In the first query, <em>PERCENT_RANK</em> and <em>CUME_DIST</em> (aliased as <em>PR</em> and <em>CD</em> respectively) rank quarterly sales across the entire two year period. Look at the value returned by <em>RANK</em> (aliased as <em>R</em>). It ranks each row in the unpartitioned window (all eight quarters) by dollar amount. Both 2011Q2 and 2010Q4 are tied for $2,000 in sales, so <em>RANK</em> assigns them the same value (2). The next row break the tie, so <em>RANK</em> continues with 4, which accounts for the “empty slot” created by the two previous rows that were tied.</p>
<p>Now examine the values returned by <em>PERCENT_RANK</em> and <em>CUME_DIST</em>. Notice how they reflect the same information as <em>RANK</em> with decimal values ranging from 0 and 1. The only difference between the two is a slight variation in their formulaic implementation, such that <em>PERCENT_RANK</em> always starts with 0 while <em>CUME_DIST</em> always starts with a value greater than 0. Specifically, <em>PERCENT_RANK</em> returns (<em>RANK</em> – 1) / (N – 1) for each row, where N is the total number of rows in the window. This always returns 0 for the first (or only) row in the window. <em>CUME_DIST</em> returns <em>RANK</em> / N, which always returns a value greater than 0 for the first row in the window (which would be 1, if there’s only row). For windows with two or more rows, both functions return 1 for the last row in the window with decimal values distributed among all the other rows.</p>
<p>The second query examines the same sales figures, only this time the result set is partitioned by year. There are no ties within each year, so <em>RANK</em> assigns the sequential numbers 1 through 4 to each of the quarters, for 2010 and 2011, by dollar amount. You can see that <em>PERCENT_RANK</em> and <em>CUME_DIST</em> perform the same <em>RANK</em> calculations as explained for the first query (only, again, partitioned by year this time).</p>
<h3><em>PERCENTILE_DISC</em> and <em>PERCENTILE_CONT</em></h3>
<p>This query also demonstrates <em>PERCENTILE_DISC</em> and <em>PERCENTILE_CONT</em>. These very similar functions each accept a percentile parameter (the desired <em>CUME_DIST</em> value) and “reach in” to the window for the row at or near that percentile. The code demonstrates by calling both functions twice, once with a percentile parameter value of .5 and once with .6, returning columns aliased as <em>PD5</em>, <em>PD6</em>, <em>PC5</em>, and <em>PC6</em>. Both functions examine the <em>CUME_DIST</em> value for each row in the window to find the one nearest to .5 and .6. The subtle difference between them is that <em>PERCENTILE_DISC</em> will return a precise (discreet) value from the row with the matching percentile (or greater), while <em>PERCENTILE_CONT</em> interpolates a value based on a continuous range. Specifically, <em>PERCENTILE_CONT</em> returns a value ranging from the row matching the specified percentile—or a calculated value higher than that (based on the specified percentile) if there is no exact match—and the row with the next higher percentile in the window. This explains the values they return in this query.</p>
<blockquote><p>Notice that these functions define their window ordering using <em>ORDER BY</em> in a <em>WITHIN GROUP</em> clause rather than in the <em>OVER</em> clause. Thus, you do not (and cannot) specify <em>ORDER BY</em> in the <em>OVER</em> clause. The <em>OVER</em> clause is still required, however, so <em>OVER</em> (with empty parentheses) must be specified even if you don’t want to partition using <em>PARTITION BY</em>.</p></blockquote>
<p>For the year 2010, the .5 percentile (<em>CUME_DIST</em> value) is located exactly on quarter 1, which had $5,000 in sales. Thus <em>PERCENTILE_DISC(.5)</em> returns 5000. There is no row in the window with a percentile of .6, so <em>PERCENTILE_DISC(.6)</em> matches up against the first row with a percentile greater than or equal to .6, which is the row for quarter 2 with $6,000 in sales, and thus returns 6000. In both cases, <em>PERCENTILE_DISC</em> returns a discreet value from a row in the window at or greater than the specified percentile. The same calculations are performed for 2011, returning 2000 for <em>PERCENTILE_DISC(.5)</em> and 3000 for <em>PERCENTILE_DISC(.6)</em>, corresponding to the $2,000 in sales for quarter 2 (percentile .5) and the $3,000 in sales for quarter 3 (percentile .75)</p>
<p>As I stated, <em>PERCENTILE_CONT</em> is very similar. It takes the same percentile parameter to find the row in the window matching that percentile. If there is no exact match, the function calculates a value based on the scale of percentiles distributed across the entire window, rather than looking ahead to the row having the next greater percentile value, as <em>PERCENTILE_DISC</em> does. Then it returns the median between that value and the value found in the row with the next greater percentile. For 2010, the .5 percentile matches up with 5000 (as before). The next percentile in the window is for .75 for 6000. The median between 5000 and 6000 is 5500 and thus, <em>PERCENTILE_CONT(.5)</em> returns 5500. There is no row in the window with a percentile of .6, so <em>PERCENTILE_CONT(.6)</em> calculates what the value for .6 would be (somewhere between 5000 and 6000, a bit closer to 5000) and then calculates the median between that value and the next percentile in the window (again, .75 for 6000). Thus, <em>PERCENTILE_CONT(.6)</em> returns 5800; slightly higher than the 5500 returned for <em>PERCENTILE_CONT(.5)</em>.</p>
<h3>Conclusion</h3>
<p>This post explained the eight new analytic functions added to T-SQL in SQL Server 2012. These new functions, plus the running and sliding aggregation capabilities covered in <a href="http://lennilobel.wordpress.com/2011/12/12/sql-server-2012-windowing-functions-part-1-of-2-running-and-sliding-aggregates/">Part 1</a>, greatly expand the windowing capabilities of the <em>OVER</em> clause available since SQL Server 2005.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lennilobel.wordpress.com/1112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lennilobel.wordpress.com/1112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lennilobel.wordpress.com/1112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lennilobel.wordpress.com/1112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lennilobel.wordpress.com/1112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lennilobel.wordpress.com/1112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lennilobel.wordpress.com/1112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lennilobel.wordpress.com/1112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lennilobel.wordpress.com/1112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lennilobel.wordpress.com/1112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lennilobel.wordpress.com/1112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lennilobel.wordpress.com/1112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lennilobel.wordpress.com/1112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lennilobel.wordpress.com/1112/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=1112&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lennilobel.wordpress.com/2012/01/03/sql-server-2012-windowing-functions-part-2-of-2-new-analytic-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e98e16e27fd8ae3e079834b881c74f72?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lennilobel</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server 2012 Windowing Functions Part 1 of 2: Running and Sliding Aggregates</title>
		<link>http://lennilobel.wordpress.com/2011/12/12/sql-server-2012-windowing-functions-part-1-of-2-running-and-sliding-aggregates/</link>
		<comments>http://lennilobel.wordpress.com/2011/12/12/sql-server-2012-windowing-functions-part-1-of-2-running-and-sliding-aggregates/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 12:51:12 +0000</pubDate>
		<dc:creator>Leonard Lobel</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2012 Code-Named "Denali"]]></category>
		<category><![CDATA[T-SQL OVER clause]]></category>
		<category><![CDATA[T-SQL running aggregates]]></category>
		<category><![CDATA[T-SQL sliding aggregates]]></category>
		<category><![CDATA[T-SQL windowing functions]]></category>

		<guid isPermaLink="false">http://lennilobel.wordpress.com/?p=1102</guid>
		<description><![CDATA[The first windowing capabilities appeared in SQL Server 2005 with the introduction of the OVER clause and a set of ranking functions (ROW_NUMBER, RANK, DENSE_RANK, and NTILE). The term “window,” as it is used here, refers to the scope of visibility from one row in a result set relative to neighboring rows in the same [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=1102&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The first <em>windowing</em> capabilities appeared in SQL Server 2005 with the introduction of the <em>OVER</em> clause and a set of ranking functions (<em>ROW_NUMBER</em>, <em>RANK</em>, <em>DENSE_RANK</em>, and <em>NTILE</em>). The term “window,” as it is used here, refers to the scope of visibility from one row in a result set relative to neighboring rows in the same result set. By default, <em>OVER</em> produces a single window over the entire result set, but its associated <em>PARTITION BY</em> clause lets you divide the result set up into distinct windows—one per partition. Furthermore, its associated <em>ORDER BY</em> clause enables cumulative calculations within each window.</p>
<p>In addition to the four ranking functions, the <em>OVER</em> clause can be used with the traditional aggregate functions (<em>SUM</em>, <em>COUNT</em>, <em>MIN</em>, <em>MAX</em>, <em>AVG</em>). This is extremely useful, because it allows you to calculate aggregations without being forced to summarize all the detail rows with a <em>GROUP BY</em> clause. However, prior to SQL Server 2012, running and sliding calculations with an associated <em>ORDER BY</em> clause was supported only for the ranking functions. Using <em>ORDER BY</em> with <em>OVER</em> for any of the aggregate functions was not allowed. This prevents running and sliding aggregations, severely limited the windowing capability of <em>OVER </em>since its introduction in SQL Server 2005.</p>
<p>Fortunately, SQL Server 2012 finally addresses this shortcoming. In this blog post, the first in a two-part article, I’ll show you how to use <em>OVER/ORDER BY</em> with all the traditional aggregate functions in SQL Server 2012 to provide running aggregates within ordered windows and partitions. I’ll also show you how to frame windows using the <em>ROWS</em> or <em>RANGE</em> clause, which adjusts the size and scope of the window and enables sliding aggregations. SQL Server 2012 also introduces eight new analytic functions that are designed specifically to work with ordered (and optionally partitioned) windows using the <em>OVER</em> clause. I will cover those new analytic functions in Part 2.</p>
<p>To demonstrate running and sliding aggregates, create a table and populate it with sample financial transactions for several different accounts, as shown below. (Note the use of the <em>DATEFROMPARTS</em> function, also new in SQL Server 2012, which is used to construct a <em>date</em> value from year, month, and day parameters.)</p>
<p><pre class="brush: plain;">CREATE TABLE TxnData (AcctId int, TxnDate date, Amount decimal)
GO

INSERT INTO TxnData (AcctId, TxnDate, Amount) VALUES
  (1, DATEFROMPARTS(2011, 8, 10), 500),  -- 5 transactions for acct 1
  (1, DATEFROMPARTS(2011, 8, 22), 250),
  (1, DATEFROMPARTS(2011, 8, 24), 75),
  (1, DATEFROMPARTS(2011, 8, 26), 125),
  (1, DATEFROMPARTS(2011, 8, 28), 175),
  (2, DATEFROMPARTS(2011, 8, 11), 500),  -- 8 transactions for acct 2
  (2, DATEFROMPARTS(2011, 8, 15), 50),
  (2, DATEFROMPARTS(2011, 8, 22), 5000),
  (2, DATEFROMPARTS(2011, 8, 25), 550),
  (2, DATEFROMPARTS(2011, 8, 27), 105),
  (2, DATEFROMPARTS(2011, 8, 27), 95),
  (2, DATEFROMPARTS(2011, 8, 29), 100),
  (2, DATEFROMPARTS(2011, 8, 30), 2500),
  (3, DATEFROMPARTS(2011, 8, 14), 500),  -- 4 transactions for acct 3
  (3, DATEFROMPARTS(2011, 8, 15), 600),
  (3, DATEFROMPARTS(2011, 8, 22), 25),
  (3, DATEFROMPARTS(2011, 8, 23), 125)</pre></p>
<h3>Running Aggregations</h3>
<p>Used by itself, the <em>OVER</em> clause operates over a window that encompasses the entire result set of a query. Windows can be partitioned in your queries using <em>OVER</em> with <em>PARTITION BY</em>, enabling partition-level aggregations to be calculated for each window. And with SQL Server 2012, an <em>ORDER BY</em> clause can also be specified with <em>OVER</em> to achieve row-level running aggregations within each window. The following code demonstrates the use of <em>OVER</em> with <em>ORDER BY</em> to produce running aggregations:</p>
<p><pre class="brush: plain;">SELECT AcctId, TxnDate, Amount,
  RAvg = AVG(Amount) OVER (PARTITION BY AcctId ORDER BY TxnDate),
  RCnt = COUNT(*)    OVER (PARTITION BY AcctId ORDER BY TxnDate),
  RMin = MIN(Amount) OVER (PARTITION BY AcctId ORDER BY TxnDate),
  RMax = MAX(Amount) OVER (PARTITION BY AcctId ORDER BY TxnDate),
  RSum = SUM(Amount) OVER (PARTITION BY AcctId ORDER BY TxnDate)
 FROM TxnData
 ORDER BY AcctId, TxnDate

AcctId TxnDate    Amount RAvg        RCnt RMin RMax RSum
------ ---------- ------ ----------- ---- ---- ---- ----
1      2011-08-10 500    500.000000  1    500  500  500
1      2011-08-22 250    375.000000  2    250  500  750
1      2011-08-24 75     275.000000  3    75   500  825
1      2011-08-26 125    237.500000  4    75   500  950
1      2011-08-28 175    225.000000  5    75   500  1125
2      2011-08-11 500    500.000000  1    500  500  500
2      2011-08-15 50     275.000000  2    50   500  550
2      2011-08-22 5000   1850.000000 3    50   5000 5550
 :</pre></p>
<p>The results of this query are partitioned (windowed) by account. Within each window, the account’s running averages, counts, minimum/maximum values, and sums are ordered by transaction date, showing the chronologically accumulated values for each account. No <em>ROWS</em> clause or <em>RANGE</em> clause is specified, so <em>ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW</em> is assumed by default. This yields a window frame size that spans from the beginning of the partition (the first row of each account) through the current row. When the account number changes, the previous window is “closed” and new calculations start running for a new window over the next account number.</p>
<h3>Sliding Aggregations</h3>
<p>You can narrow each account’s window by framing it with a <em>ROWS BETWEEN n PRECEDING AND CURRENT ROW</em> clause within the <em>OVER</em> clause. This enables sliding calculations, as demonstrated by this slightly modified version of the previous query:</p>
<p><pre class="brush: plain;">SELECT AcctId, TxnDate, Amount,
  SAvg = AVG(Amount) OVER (PARTITION BY AcctId ORDER BY TxnDate ROWS BETWEEN 2 PRECEDING AND CURRENT ROW),
  SCnt = COUNT(*)    OVER (PARTITION BY AcctId ORDER BY TxnDate ROWS 2 PRECEDING),
  SMin = MIN(Amount) OVER (PARTITION BY AcctId ORDER BY TxnDate ROWS 2 PRECEDING),
  SMax = MAX(Amount) OVER (PARTITION BY AcctId ORDER BY TxnDate ROWS 2 PRECEDING),
  SSum = SUM(Amount) OVER (PARTITION BY AcctId ORDER BY TxnDate ROWS 2 PRECEDING)
 FROM TxnData
 ORDER BY AcctId, TxnDate

AcctId TxnDate    Amount SAvg        SCnt SMin SMax SSum
------ ---------- ------ ----------- ---- ---- ---- ----
1      2011-08-10 500    500.000000  1    500  500  500
1      2011-08-22 250    375.000000  2    250  500  750
1      2011-08-24 75     275.000000  3    75   500  825
1      2011-08-26 125    150.000000  3    75   250  450
1      2011-08-28 175    125.000000  3    75   175  375
2      2011-08-11 500    500.000000  1    500  500  500
2      2011-08-15 50     275.000000  2    50   500  550
2      2011-08-22 5000   1850.000000 3    50   5000 5550
 :</pre></p>
<p>This query specifies <em>ROWS BETWEEN 2 PRECEDING AND CURRENT ROW</em> in the <em>OVER</em> clause for the <em>RAvg</em> column, overriding the default window size. Specifically, it frames the window within each account’s partition to a maximum of three rows: the current row, the row before it, and one more row before that one. Once the window expands to three rows, it stops growing and starts sliding down the subsequent rows until a new partition (the next account) is encountered. The <em>BETWEEN…AND CURRENT ROW</em> keywords that specify the upper bound of the window are assumed default, so to reduce code clutter, the other column definitions specify just the lower bound of the window with the shorter variation <em>ROWS 2 PRECEDING</em>.</p>
<p>Notice how the window “slides” within each account. For example, the sliding maximum for account 1 drops from 500 to 250 in the fourth row, because 250 is the largest value in the window of three rows that begins two rows earlier—and the 500 from the very first row is no longer visible in that window. Similarly, the sliding sum for each account is based on the defined window. Thus, the sliding sum of 375 on the last row of account 1 is the total sum of that row (175) plus the two preceding rows (75 + 125) only—not the total sum for all transactions in the entire account, as the running sum had calculated.</p>
<h3>Using <em>RANGE</em> versus <em>ROWS</em></h3>
<p>Finally, <em>RANGE</em> can be used instead of <em>ROWS</em> to handle “ties” within a window. While <em>ROWS</em> treats each row in the window distinctly, <em>RANGE</em> will merge rows containing duplicate <em>ORDER BY</em> values, as demonstrated by the following query:</p>
<p><pre class="brush: plain;">SELECT AcctId, TxnDate, Amount,
 SumByRows = SUM(Amount) OVER (ORDER BY TxnDate ROWS UNBOUNDED PRECEDING),
 SumByRange = SUM(Amount) OVER (ORDER BY TxnDate RANGE UNBOUNDED PRECEDING)
 FROM TxnData
 WHERE AcctId = 2
 ORDER BY TxnDate

AcctId TxnDate    Amount SumByRows SumByRange
------ ---------- ------ --------- ----------
2      2011-08-11 500    500       500
2      2011-08-15 50     550       550
2      2011-08-22 5000   5550      5550
2      2011-08-25 550    6100      6100
2      2011-08-27 105    6205      6300
2      2011-08-27 95     6300      6300
2      2011-08-29 100    6400      6400
2      2011-08-30 2500   8900      8900</pre></p>
<p>In this result set, <em>ROWS</em> and <em>RANGE</em> both return the same values, with the exception of the fifth row. Because the fifth and sixth rows are both tied for the same date (8/27/2011), <em>RANGE</em> returns the combined running sum for both rows. The seventh row (for 8/29/2011) breaks the tie, and <em>ROWS</em> “catches up” with <em>RANGE</em> to return running totals for the rest of the window.</p>
<h3>Conclusion</h3>
<p>Windowing functions using the <em>OVER</em> clause have been greatly enhanced in SQL Server 2012. In addition to the 4 ranking functions, running and sliding calculations with <em>OVER/ORDER BY</em> is now supported for all the traditional aggregate functions as well. SQL Server 2012 also introduces eight new analytic functions that are designed specifically to work with ordered (and optionally partitioned) windows using the <em>OVER</em> clause. Stay tuned for Part 2, which will show you how to use these new analytic windowing functions.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lennilobel.wordpress.com/1102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lennilobel.wordpress.com/1102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lennilobel.wordpress.com/1102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lennilobel.wordpress.com/1102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lennilobel.wordpress.com/1102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lennilobel.wordpress.com/1102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lennilobel.wordpress.com/1102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lennilobel.wordpress.com/1102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lennilobel.wordpress.com/1102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lennilobel.wordpress.com/1102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lennilobel.wordpress.com/1102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lennilobel.wordpress.com/1102/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lennilobel.wordpress.com/1102/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lennilobel.wordpress.com/1102/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=1102&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lennilobel.wordpress.com/2011/12/12/sql-server-2012-windowing-functions-part-1-of-2-running-and-sliding-aggregates/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e98e16e27fd8ae3e079834b881c74f72?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lennilobel</media:title>
		</media:content>
	</item>
		<item>
		<title>Download VSLive Orlando SQL Server 2012 Workshop Materials</title>
		<link>http://lennilobel.wordpress.com/2011/12/09/download-vslive-orlando-sql-server-2012-workshop-materials/</link>
		<comments>http://lennilobel.wordpress.com/2011/12/09/download-vslive-orlando-sql-server-2012-workshop-materials/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 02:35:58 +0000</pubDate>
		<dc:creator>Leonard Lobel</dc:creator>
				<category><![CDATA[Community Events]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2012 Code-Named "Denali"]]></category>

		<guid isPermaLink="false">http://lennilobel.wordpress.com/?p=1141</guid>
		<description><![CDATA[I just got back from another great VSLive! A special thanks to all the attendees who were at my SQL Server workshop on Monday. You guys had great questions and were a lot of fun. As promised, I&#8217;ve posted the very latest version of my slides and code for you to grab right here: http://bit.ly/VSL2011SQLOrlando [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=1141&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I just got back from another great VSLive! A special thanks to all the attendees who were at my SQL Server workshop on Monday. You guys had great questions and were a lot of fun. As promised, I&#8217;ve posted the very latest version of my slides and code for you to grab right here:</p>
<p><a href="http://bit.ly/VSL2011SQLOrlando">http://bit.ly/VSL2011SQLOrlando</a></p>
<p>If you missed VSLive! in Orlando, catch us in Vegas next March. In addition to the full-day SQL 2012 workshop, I&#8217;ll be giving breakout sessions on SQL Server Data Tools (SSDT) and .NET 4.0 Data Access. Enjoy!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lennilobel.wordpress.com/1141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lennilobel.wordpress.com/1141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lennilobel.wordpress.com/1141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lennilobel.wordpress.com/1141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lennilobel.wordpress.com/1141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lennilobel.wordpress.com/1141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lennilobel.wordpress.com/1141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lennilobel.wordpress.com/1141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lennilobel.wordpress.com/1141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lennilobel.wordpress.com/1141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lennilobel.wordpress.com/1141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lennilobel.wordpress.com/1141/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lennilobel.wordpress.com/1141/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lennilobel.wordpress.com/1141/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=1141&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lennilobel.wordpress.com/2011/12/09/download-vslive-orlando-sql-server-2012-workshop-materials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e98e16e27fd8ae3e079834b881c74f72?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lennilobel</media:title>
		</media:content>
	</item>
		<item>
		<title>Throwing Errors in SQL Server 2012</title>
		<link>http://lennilobel.wordpress.com/2011/11/12/throwing-errors-in-sql-server-2012/</link>
		<comments>http://lennilobel.wordpress.com/2011/11/12/throwing-errors-in-sql-server-2012/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 20:49:31 +0000</pubDate>
		<dc:creator>Leonard Lobel</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2012 Code-Named "Denali"]]></category>

		<guid isPermaLink="false">http://lennilobel.wordpress.com/?p=1030</guid>
		<description><![CDATA[Error handling in T-SQL was very difficult to implement properly before SQL Server 2005 introduced the TRY/CATCH construct, a feature loosely based on .NET’s try/catch structured exception handling model. The CATCH block gives you a single place to code error handling logic in the event that a problem occurs anywhere inside the TRY block above [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=1030&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Error handling in T-SQL was very difficult to implement properly before SQL Server 2005 introduced the <em>TRY/CATCH</em> construct, a feature loosely based on .NET’s <em>try/catch</em> structured exception handling model. The <em>CATCH</em> block gives you a single place to code error handling logic in the event that a problem occurs anywhere inside the <em>TRY</em> block above it. Before <em>TRY/CATCH</em>, it was necessary to always check for error conditions after every operation by testing the built-in system function <em>@@ERROR</em>. Not only did code become cluttered with the many <em>@@ERROR</em> tests, developers (being humans) would too often forget to test <em>@@ERROR</em> in every needed place, causing many unhandled exceptions to go unnoticed.</p>
<p>In SQL Server 2005, <em>TRY/CATCH </em>represented a vast improvement over constantly testing <em>@@ERROR</em>, but <em>RAISERROR</em> has (until SQL Server 2012) remained as the only mechanism for generating your own errors. In SQL Server 2012, the new <em>THROW </em>statement (again, borrowed from <em>throw </em>in the .NET model) is the recommended alternative way to raise exceptions in your T-SQL code (although <em>RAISERROR </em>does retain several capabilities that <em>THROW </em>lacks, as I’ll explain shortly).</p>
<h2>Re-Throwing Exceptions</h2>
<p>The new <em>THROW </em>statement can be used in two ways. First, and as I just stated, it can serve as an alternative to <em>RAISERROR</em>, allowing your code to generate errors when it detects an unresolvable condition in processing. Used for this purpose, the <em>THROW</em> statement accepts parameters for the error code, description, and state, and works much like <em>RAISERROR</em>. A more specialized use of <em>THROW</em> takes no parameters, and can appear only inside a <em>CATCH</em> block. In this scenario, an unexpected error occurs in the <em>TRY</em> block above, triggering execution of the <em>CATCH </em>block. Inside the <em>CATCH</em> block, you can perform general error handling (for example, logging the error, or rolling back a transaction), and then issue a <em>THROW </em>statement with no parameters. This will re-throw the original error that occurred—with its code, message, severity, and state intact—back up to the client, so the error can be caught and handled at the application level as well. This is an easy and elegant way for you to implement a segmented exception handling strategy between the database and application layers.</p>
<p>In contrast, <em>RAISERROR </em>always raises a new error. Thus, it can only simulate re-throwing the original error by capturing the <em>ERROR_MESSAGE</em>, <em>ERROR_SEVERITY</em>, and <em>ERROR_STATE</em> in the <em>CATCH</em> block and using their values to raise a new error. Using <em>THROW</em> for this purpose is much more simple and direct, as demonstrated with the following code:</p>
<p><pre class="brush: plain;">CREATE TABLE ErrorLog(ErrAt datetime2, Severity varchar(max), ErrMsg varchar(max))
GO

BEGIN TRY
  DECLARE @Number int = 5 / 0;
END TRY
BEGIN CATCH
  -- Log the error info, then re-throw it
  INSERT INTO ErrorLog VALUES(SYSDATETIME(), ERROR_SEVERITY(), ERROR_MESSAGE());
  THROW;
END CATCH</pre></p>
<p>In this code’s <em>CATCH </em>block, error information is recorded to the <em>ErrorLog </em>table and then the original error (divide by zero) is re-thrown for the client to catch:</p>
<pre><span style="font-family:Consolas;color:red;">Msg 8134, Level 16, State 1, Line 4
Divide by zero error encountered.</span></pre>
<p>To confirm that the error was logged by the <em>CATCH</em> block as expected before being re-thrown, query the <em>ErrorLog</em> table:</p>
<p><pre class="brush: plain;">SELECT * FROM ErrorLog</pre></p>
<pre><span style="font-family:Consolas;">ErrAt                     Severity ErrMsg
------------------------- -------- ------------------------------------------
2011-10-30 14:14:35.336   16       Divide by zero error encountered.</span></pre>
<h2>Comparing <em>THROW</em> and <em>RAISERROR</em></h2>
<p>The following table summarizes the notable differences between <em>THROW</em> and <em>RAISERROR</em>:</p>
<table style="border-bottom:1px solid black;" width="640" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="border-top:1px solid black;padding-left:4px;font-weight:bold;background-color:#e0e0e0;" valign="top">THROW</td>
<td style="border-top:1px solid black;padding-left:4px;font-weight:bold;background-color:#e0e0e0;" valign="top">RAISERROR</td>
</tr>
<tr>
<td style="border-top:1px solid black;padding-left:4px;" valign="top">Can only generate user exceptions (unless re-throwing in <em>CATCH</em> block)</td>
<td style="border-top:1px solid black;padding-left:4px;" valign="top">Can generate user (&gt;= 50000) and system (&lt; 50000) exceptions</td>
</tr>
<tr>
<td style="border-top:1px solid black;padding-left:4px;" valign="top">Supplies ad-hoc text; doesn’t utilize <em>sys.messages</em></td>
<td style="border-top:1px solid black;padding-left:4px;" valign="top">Requires user messages defined in <em>sys.messages</em> (except for code 50000)</td>
</tr>
<tr>
<td style="border-top:1px solid black;padding-left:4px;" valign="top">Doesn’t support token substitutions</td>
<td style="border-top:1px solid black;padding-left:4px;" valign="top">Supports token substitutions</td>
</tr>
<tr>
<td style="border-top:1px solid black;padding-left:4px;" valign="top">Always uses severity level 16 (unless re-throwing in a <em>CATCH</em> block)</td>
<td style="border-top:1px solid black;padding-left:4px;" valign="top">Can set any severity level</td>
</tr>
<tr>
<td style="border-top:1px solid black;padding-left:4px;" valign="top">Can re-throw original exception caught in the <em>TRY</em> block</td>
<td style="border-top:1px solid black;padding-left:4px;" valign="top">Always generates a new exception; the original exception is lost to the client</td>
</tr>
<tr>
<td style="border-top:1px solid black;padding-left:4px;" valign="top">Error messages are buffered, and don’t appear in real-time</td>
<td style="border-top:1px solid black;padding-left:4px;" valign="top">Supports <em>WITH NOWAIT </em>to immediate flush buffered output on error</td>
</tr>
</tbody>
</table>
<p>A user exception is an error with a code of 50000 or higher that you define for your application’s use. System exceptions are defined by SQL Server and have error codes lower than 50000. You can use the new <em>THROW</em> statement to generate and raise user exceptions, but not system exceptions. Only <em>RAISERROR</em> can be used to throw system exceptions. Note, however, that when <em>THROW</em> is used in a <em>CATCH</em> block to re-throw the exception from a <em>TRY</em> block, the actual original exception—even if it’s a system exception—will get thrown (as demonstrated in the previous “divide by zero” example).</p>
<p>When <em>RAISERROR</em> is used without an error code, SQL Server assigns an error code of 50000 and expects you to supply an ad-hoc message to associate with the error. The <em>THROW</em> statement always expects you to supply an ad-hoc message for the error, as well as a user error code of 50000 or higher. Thus, the following two statements are equivalent:</p>
<p><pre class="brush: plain;">THROW 50000, 'An error occurred querying the table.', 1;
RAISERROR ('An error occurred querying the table.', 16, 1);</pre></p>
<p>Both these statements raise an error with code 50000, severity 16, state 1, and the same message text. Compatibility between the two keywords ends there, however, as varying usages impose different rules (as summarized in Table 2-4). For example, only <em>RAISERROR </em>supports token substitution:</p>
<p><pre class="brush: plain;">RAISERROR ('An error occurred querying the %s table.', 16, 1, 'Customer');</pre></p>
<pre><span style="font-family:Consolas;color:red;">Msg 50000, Level 16, State 1, Line 22
An error occurred querying the Customer table.</span></pre>
<p><em>THROW</em> has no similar capability. Also, while <em>RAISERROR </em>lets you specify any severity level, <em>THROW </em>will always generate an error with a severity level of 16. This is significant, as level 11 and higher indicates more serious errors than level 10 and lower. For example:</p>
<p><pre class="brush: plain;">RAISERROR ('An error occurred querying the table.', 10, 1);</pre></p>
<pre><span style="font-family:Consolas;">An error occurred querying the table.</span></pre>
<p>Because the severity is 10, this error does not echo the error code, level, state, and line number, and is displayed in black rather than the usual red that is used for severity levels higher than 10. In contrast, <em>THROW</em> cannot be used to signal a non-severe error.</p>
<p>The last important difference between the two keywords is the <em>RAISERROR</em> association with <em>sys.messages</em>. In particular, <em>RAISERROR</em> requires that you call <em>sys.sp_addmessage</em> to define error messages associated with user error codes higher than 50000. As explained, the <em>RAISERROR</em> syntax in our earlier examples uses an error code of 50000, and is the only supported syntax that lets you supply an ad-hoc message instead of utilizing <em>sys.messages</em>.</p>
<p>The following code demonstrates how to define customer user error messages for <em>RAISERROR</em>. First (and only once), a tokenized message for user error code 66666 is added to <em>sys.messages</em>. Thereafter, <em>RAISERROR</em> references the error by its code, and also supplies values for token replacements that are applied to the message’s text in <em>sys.messages</em>.</p>
<p><pre class="brush: plain;">EXEC sys.sp_addmessage 66666, 16, 'There is already a %s named %s.';
RAISERROR(66666, 16, 1, 'cat', 'morris');</pre></p>
<pre><span style="font-family:Consolas;color:red;">Msg 66666, Level 16, State 1, Line 34
There is already a cat named morris.</span></pre>
<p>The <em>THROW </em>statement has no such requirement. You supply any ad-hoc message text with <em>THROW</em>. You don’t need to separately manage <em>sys.messages</em>, but this also means that <em>THROW</em> can’t (directly) leverage centrally managed error messages in <em>sys.messages</em> like <em>RAISERROR </em>does. Fortunately, the <em>FORMATMESSAGE </em>function provides a workaround, if you want to take advantage of the same capability with <em>THROW</em>. You just need to take care and make sure that the same error code is specified in the two places that you need to reference it (once for <em>FORMATMESSAGE</em> and once for <em>THROW</em>), as shown here:</p>
<p><pre class="brush: plain;">DECLARE @Message varchar(max) = FORMATMESSAGE(66666, 'dog', 'snoopy');
THROW 66666, @Message, 1;</pre></p>
<pre><span style="font-family:Consolas;color:red;">Msg 66666, Level 16, State 1, Line 40
There is already a dog named snoopy.</span></pre>
<h2>Summary</h2>
<p>Starting in SQL Server 2012, the <em>THROW</em> keyword should be used instead of <em>RAISERROR</em> to raise your own errors. <em>THROW</em> can also be used inside <em>CATCH</em> blocks to raise the original error that occurred within the <em>TRY</em> block. However, <em>RAISERROR</em> is still supported, and can be used to raise system errors or errors with any lesser severity, when necessary. You can start working with <em>THROW</em> by downloading SQL Server 2012 &#8220;Denali&#8221; CTP3 from <a href="http://bit.ly/DenaliCTP3">http://bit.ly/DenaliCTP3</a>. Try not too have <em>too</em> much fun throwing errors! <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lennilobel.wordpress.com/1030/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lennilobel.wordpress.com/1030/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lennilobel.wordpress.com/1030/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lennilobel.wordpress.com/1030/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lennilobel.wordpress.com/1030/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lennilobel.wordpress.com/1030/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lennilobel.wordpress.com/1030/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lennilobel.wordpress.com/1030/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lennilobel.wordpress.com/1030/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lennilobel.wordpress.com/1030/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lennilobel.wordpress.com/1030/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lennilobel.wordpress.com/1030/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lennilobel.wordpress.com/1030/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lennilobel.wordpress.com/1030/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=1030&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lennilobel.wordpress.com/2011/11/12/throwing-errors-in-sql-server-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e98e16e27fd8ae3e079834b881c74f72?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lennilobel</media:title>
		</media:content>
	</item>
		<item>
		<title>Book Announcement! Introducing &#8220;Programming Microsoft SQL Server 2012&#8243;</title>
		<link>http://lennilobel.wordpress.com/2011/11/01/book-announcement-introducing-programming-microsoft-sql-server-2012/</link>
		<comments>http://lennilobel.wordpress.com/2011/11/01/book-announcement-introducing-programming-microsoft-sql-server-2012/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 00:00:49 +0000</pubDate>
		<dc:creator>Leonard Lobel</dc:creator>
				<category><![CDATA[Community Events]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2012 Code-Named "Denali"]]></category>

		<guid isPermaLink="false">http://lennilobel.wordpress.com/?p=968</guid>
		<description><![CDATA[I’m very happy to announce that I’ll be authoring a new book on SQL Server 2012, code-named “Denali.” The full title, “Programming Microsoft SQL Server 2012” will technically be published by O’Reilly, yet it will be branded as a Microsoft Press book. O’Reilly recently acquired MS Press, but retained the Microsoft logo and black/red theme, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=968&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I’m very happy to announce that I’ll be authoring a new book on SQL Server 2012, code-named “Denali.” The full title, “Programming Microsoft SQL Server 2012” will technically be published by O’Reilly, yet it will be branded as a Microsoft Press book. O’Reilly recently acquired MS Press, but retained the Microsoft logo and black/red theme, which I’m really glad about. Although O’Reilly is a big name, the MS Press branding still carries more clout. And to be honest, I greatly prefer having a cool tool to a weird animal on the cover.</p>
<p>This book is an update to the SQL Server 2008 edition I wrote three years ago, with many similarities but also some very notable differences. I’m extremely pleased to once again team together with Andrew Brust, who will be writing the chapters on SQL CLR, column stores, BI, and SQL Azure. Andrew was my co-author for the 2008 edition and lead author of the original 2005 edition, so this is actually his <em>third</em> time around on this book. Both previous editions literally burst at the seams in their zeal to cover the entire SQL Server stack. This time around, in consideration of the many readily available BI-focused books, the editors decided to distill the BI footprint of the new Denali book (which accounted for roughly a whole third of the previous 1,000+ page 2008 edition) down to a single overview-style chapter. This simultaneously brings the page count down a little, while actually opening more space for expanded coverage of the relational database engine. As a result, this new book is more narrowly (and uniquely) focused on programming SQL Server for transactional line-of-business applications built with .NET and Visual Studio.</p>
<p>So busy days lie ahead. I’ve actually spent nearly a year already gearing up on Denali, since attending the Denali SDR in Redmond last October. Here are just some of the new topics planned for the 2012 edition:</p>
<ul>
<li>SQL Server Data Tools</li>
<li>SQL Azure</li>
<li>Column store indexes</li>
<li>Sequences</li>
<li>Windowing function (OVER BY) improvements</li>
<li>Server-side paging</li>
<li>FileTable (FILESTREAM + hierarchyid = logical file system)</li>
<li>Metadata discovery</li>
<li>Spatial enhancements (curves, FULLGLOBE)</li>
<li>Contained Databases</li>
<li>Self-Service Reporting (Crescent)</li>
<li>Entity Framework &amp; LINQ</li>
<li>WCF Data Services &amp; WCF RIA Services</li>
</ul>
<p>This list is by no means exhaustive, and may still change, but it does give a good idea of what to expect. Also, this is in addition to updated coverage from the previous edition that includes broader treatment of topics such as table-valued parameters, SQL Server Audit, and more.</p>
<p>With luck, the book should be out by Q2 2012. I’m looking forward to the work in store, and hope to produce the best piece of work I can. Along the way, I’ll be blogging more previews of what’s to come. So stay tuned, and thanks for reading.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lennilobel.wordpress.com/968/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lennilobel.wordpress.com/968/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lennilobel.wordpress.com/968/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lennilobel.wordpress.com/968/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lennilobel.wordpress.com/968/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lennilobel.wordpress.com/968/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lennilobel.wordpress.com/968/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lennilobel.wordpress.com/968/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lennilobel.wordpress.com/968/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lennilobel.wordpress.com/968/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lennilobel.wordpress.com/968/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lennilobel.wordpress.com/968/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lennilobel.wordpress.com/968/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lennilobel.wordpress.com/968/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=968&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lennilobel.wordpress.com/2011/11/01/book-announcement-introducing-programming-microsoft-sql-server-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e98e16e27fd8ae3e079834b881c74f72?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lennilobel</media:title>
		</media:content>
	</item>
		<item>
		<title>Download VSLive Redmond SQL Server Workshop Materials</title>
		<link>http://lennilobel.wordpress.com/2011/10/24/download-vslive-redmond-sql-server-workshop-materials/</link>
		<comments>http://lennilobel.wordpress.com/2011/10/24/download-vslive-redmond-sql-server-workshop-materials/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 02:15:02 +0000</pubDate>
		<dc:creator>Leonard Lobel</dc:creator>
				<category><![CDATA[Community Events]]></category>

		<guid isPermaLink="false">http://lennilobel.wordpress.com/?p=1021</guid>
		<description><![CDATA[Visual Studio Live just wrapped up in Redmond, and it was a very successful conference. As promised, I&#8217;ve posted the slides and code for my SQL Server workshop for you to download. You can grab the stuff here: http://bit.ly/VSL2011SQLRedmond Thanks to the great crowd we had on Friday. You guys were a lot of fun, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=1021&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Visual Studio Live just wrapped up in Redmond, and it was a very successful conference. As promised, I&#8217;ve posted the slides and code for my SQL Server workshop for you to download. You can grab the stuff here: </p>
<p><a target="_blank" href="http://bit.ly/VSL2011SQLRedmond">http://bit.ly/VSL2011SQLRedmond</a></p>
<p>Thanks to the great crowd we had on Friday. You guys were a lot of fun, and now I&#8217;m looking forward to doing it again in Orlando in December!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lennilobel.wordpress.com/1021/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lennilobel.wordpress.com/1021/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lennilobel.wordpress.com/1021/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lennilobel.wordpress.com/1021/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lennilobel.wordpress.com/1021/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lennilobel.wordpress.com/1021/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lennilobel.wordpress.com/1021/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lennilobel.wordpress.com/1021/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lennilobel.wordpress.com/1021/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lennilobel.wordpress.com/1021/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lennilobel.wordpress.com/1021/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lennilobel.wordpress.com/1021/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lennilobel.wordpress.com/1021/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lennilobel.wordpress.com/1021/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=1021&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lennilobel.wordpress.com/2011/10/24/download-vslive-redmond-sql-server-workshop-materials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e98e16e27fd8ae3e079834b881c74f72?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lennilobel</media:title>
		</media:content>
	</item>
		<item>
		<title>Received Microsoft 2011 MVP Award for SQL Server!</title>
		<link>http://lennilobel.wordpress.com/2011/10/12/received-microsoft-2011-mvp-award-for-sql-server/</link>
		<comments>http://lennilobel.wordpress.com/2011/10/12/received-microsoft-2011-mvp-award-for-sql-server/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 23:31:42 +0000</pubDate>
		<dc:creator>Leonard Lobel</dc:creator>
				<category><![CDATA[Community Events]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Microsoft MVP]]></category>
		<category><![CDATA[MVP]]></category>

		<guid isPermaLink="false">http://lennilobel.wordpress.com/?p=1000</guid>
		<description><![CDATA[I&#8217;m extremely happy to announce that I&#8217;ve just earned Microsoft&#8217;s 2011 MVP (Most Valuable Professional) Award for SQL Server! My MVP profile is online at https://mvp.support.microsoft.com/profile/Lobel. Microsoft recognizes independent software professionals who actively share their expertise and knowledge throughout the technical community with the MVP award. There are just over 4,000 MVPs worldwide, of which [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=1000&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m extremely happy to announce that I&#8217;ve just earned Microsoft&#8217;s 2011 MVP (Most Valuable Professional) Award for SQL Server! My MVP profile is online at <a href="https://mvp.support.microsoft.com/profile/Lobel" target="_blank">https://mvp.support.microsoft.com/profile/Lobel</a>.</p>
<p>Microsoft recognizes independent software professionals who actively share their expertise and knowledge throughout the technical community with the MVP award. There are just over 4,000 MVPs worldwide, of which there are only 279 MVPs for SQL Server (as of October 2011). So it&#8217;s a great thrill and honor for me to join this very select group of dedicated individuals.</p>
<p>There&#8217;s nothing I enjoy more than helping other developers learn and grow, and that&#8217;s exactly what the MVP award is all about. So thanks to all of you out there for your readership, and I look forward to many more years of speaking and writing on SQL Server, .NET, and all things Microsoft!</p>
<p><a href="http://lennilobel.files.wordpress.com/2011/10/mvp-award-2011.jpg"><img class="alignnone size-full wp-image-1006" title="MVP Award 2011" src="http://lennilobel.files.wordpress.com/2011/10/mvp-award-2011.jpg?w=780&#038;h=585" alt="" width="780" height="585" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lennilobel.wordpress.com/1000/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lennilobel.wordpress.com/1000/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lennilobel.wordpress.com/1000/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lennilobel.wordpress.com/1000/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lennilobel.wordpress.com/1000/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lennilobel.wordpress.com/1000/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lennilobel.wordpress.com/1000/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lennilobel.wordpress.com/1000/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lennilobel.wordpress.com/1000/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lennilobel.wordpress.com/1000/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lennilobel.wordpress.com/1000/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lennilobel.wordpress.com/1000/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lennilobel.wordpress.com/1000/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lennilobel.wordpress.com/1000/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=1000&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lennilobel.wordpress.com/2011/10/12/received-microsoft-2011-mvp-award-for-sql-server/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e98e16e27fd8ae3e079834b881c74f72?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lennilobel</media:title>
		</media:content>

		<media:content url="http://lennilobel.files.wordpress.com/2011/10/mvp-award-2011.jpg" medium="image">
			<media:title type="html">MVP Award 2011</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a Helpful Extension Method for XAML Visibility</title>
		<link>http://lennilobel.wordpress.com/2011/10/07/creating-a-helpful-extension-method-for-xaml-visibility/</link>
		<comments>http://lennilobel.wordpress.com/2011/10/07/creating-a-helpful-extension-method-for-xaml-visibility/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 11:28:34 +0000</pubDate>
		<dc:creator>Leonard Lobel</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[XAML]]></category>
		<category><![CDATA[Silverlight Visibility]]></category>
		<category><![CDATA[WPF Visibility]]></category>
		<category><![CDATA[XAML Visibility]]></category>

		<guid isPermaLink="false">http://lennilobel.wordpress.com/?p=894</guid>
		<description><![CDATA[Used recklessly, extension methods are potentially evil. But judiciously applied, they can be extremely helpful. In this short post (well, short for me), I’ll show you how to create an extension method for the bool class that will simplify your .NET code in XAML-based apps (either WPF or Silverlight). In particular, this extension method addresses [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=894&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Used recklessly, extension methods are potentially evil. But judiciously applied, they can be extremely helpful. In this short post (well, short for me), I’ll show you how to create an extension method for the <em>bool</em> class that will simplify your .NET code in XAML-based apps (either WPF or Silverlight). In particular, this extension method addresses the fact that the <em>Visibility </em>property of UI controls in XAML is not a Boolean (true/false) value (as has traditionally been the case for both Windows Forms and ASP.NET). Instead, it’s one of three possible enumerated constant values: <em>Hidden</em>, <em>Collapsed</em>, and <em>Visible</em>.</p>
<p><em>Visible</em> obviously means “visible,” while both <em>Hidden</em> and <em>Collapsed </em>mean “invisible.” The difference between <em>Hidden</em> and <em>Collapsed</em> is merely whether or not the invisible control occupies blank space on the screen that it would occupy if it were visible. <em>Collapsed</em> consumes no space, while <em>Hidden</em> does.</p>
<p>It’s nice to have the three options, but in most cases you’ll find that you just need the two options <em>Visible </em>and <em>Collapsed</em>. If you’re setting visibility to XAML controls using these two enums, you’ve probably noticed that it’s just not as clean as it is with Windows Forms or ASP.NET controls. You typically already have a Boolean value—either as a simple variable, or an expression—that determines whether the control should be visible or not. You could use that value to enable or disable the control, as the <em>IsEnabled</em> property is also a Boolean, but you can’t assign it to the <em>Visibility </em>property because that property expects one of the three <em>Visibility </em>enumerations—not a Boolean. That’s frustrating, because from a UX (user experience) perspective, where these concepts are used to convey “availability” to the user, hiding/showing controls versus enabling/disabling them is a subtlety of UI design. So developers should be able to think (and code) freely in terms of Booleans for both <em>IsEnabled</em> and <em>Visibility</em>.</p>
<p>Consider the C# code to manipulate the <em>Visibility</em> and <em>IsEnabled</em> properties of a button control:</p>
<pre style="background-color:#fcfbe2;border:solid 1px black;padding:8px;">OpenCustomerButton.IsEnabled = <span style="color:blue;">false</span>;
OpenCustomerButton.IsEnabled = <span style="color:blue;">true</span>;
OpenCustomerButton.Visibility = <span style="color:#2b91af;">Visibility</span>.Collapsed;
OpenCustomerButton.Visibility = <span style="color:#2b91af;">Visibility</span>.Visible;

<span style="color:blue;">bool</span> isAvailable = <span style="color:blue;">true</span>;
OpenCustomerButton.IsEnabled = isAvailable;
OpenCustomerButton.Visibility = (isAvailable ? <span style="color:#2b91af;">Visibility</span>.Collapsed : <span style="color:#2b91af;">Visibility</span>.Visible);

<span style="color:#008014;">// Set the button's visibility according another button's enabled/disabled state</span>
OpenCustomerButton.Visibility = (ManageCustomersButton.IsEnabled ? <span style="color:#2b91af;">Visibility</span>.Visible : <span style="color:#2b91af;">Visibility</span>.Collapsed);</pre>
<p>You can see that because <em>Visibility </em>takes the enum rather than a <em>bool</em>, it’s harder to work with than <em>IsEnabled</em>, and just isn’t as neat. But we can do something about this. How? By writing a simple (one-line!) extension method that adds a <em>ToVisibility </em>method to the <em>bool </em>class:</p>
<p><pre class="brush: plain;">public static class BoolExtensions
{
  public static Visibility ToVisibility(this bool isVisible)
  {
    return (isVisible ? Visibility.Visible : Visibility.Collapsed);
  }
}</pre></p>
<p>Now the same UI code is much easier to read and write:</p>
<pre style="border:1px solid black;background-color:#fcfbe2;padding:8px;">OpenCustomerButton.IsEnabled = <span style="color:blue;">false</span>;
OpenCustomerButton.IsEnabled = <span style="color:blue;">true</span>;
OpenCustomerButton.Visibility = <span style="color:blue;">false</span><span style="background-color:yellow;">.ToVisibility()</span>;
OpenCustomerButton.Visibility = <span style="color:blue;">true</span><span style="background-color:yellow;">.ToVisibility()</span>;

<span style="color:blue;">bool</span> isAvailable = <span style="color:blue;">true</span>;
OpenCustomerButton.IsEnabled = isAvailable;
OpenCustomerButton.Visibility = isAvailable<span style="background-color:yellow;">.ToVisibility()</span>;

<span style="color:#008014;">// Set the button's visibility according to another button's enabled/disabled state</span>
OpenCustomerButton.Visibility = ManageCustomersButton.IsEnabled<span style="background-color:yellow;">.ToVisibility()</span>;</pre>
<p>Like? Me too. Neatness counts!</p>
<p>It would be even better if we could instead extend every <em>UIElement </em>with a Boolean <em>property </em>called <em>IsVisible</em>, and embed the conversion logic bi-directionally in the property&#8217;s getter and setter. But, unfortunately, you cannot create extension properties in .NET, only extension methods. So extending <em>bool</em> with a <em>ToVisibility</em> method is the next best thing.</p>
<p>One more tip: Put the <em>BoolExtensions </em>class inside a common code namespace that all your XAML classes import, so <em>ToVisibility</em> is always available without needing to add an extra <em>using </em>statement.</p>
<p>Remember, abusing extension methods quickly leads to messy, buggy code. Instead, find appropriate uses for extension methods that yield cleaner, tighter code. That is all. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lennilobel.wordpress.com/894/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lennilobel.wordpress.com/894/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lennilobel.wordpress.com/894/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lennilobel.wordpress.com/894/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lennilobel.wordpress.com/894/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lennilobel.wordpress.com/894/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lennilobel.wordpress.com/894/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lennilobel.wordpress.com/894/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lennilobel.wordpress.com/894/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lennilobel.wordpress.com/894/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lennilobel.wordpress.com/894/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lennilobel.wordpress.com/894/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lennilobel.wordpress.com/894/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lennilobel.wordpress.com/894/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=894&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lennilobel.wordpress.com/2011/10/07/creating-a-helpful-extension-method-for-xaml-visibility/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e98e16e27fd8ae3e079834b881c74f72?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lennilobel</media:title>
		</media:content>
	</item>
		<item>
		<title>Community Service Week</title>
		<link>http://lennilobel.wordpress.com/2011/09/13/community-service-week/</link>
		<comments>http://lennilobel.wordpress.com/2011/09/13/community-service-week/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 15:29:12 +0000</pubDate>
		<dc:creator>Leonard Lobel</dc:creator>
				<category><![CDATA[Community Events]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Developer Tools (SSDT) Code-Named "Juneau"]]></category>

		<guid isPermaLink="false">http://lennilobel.wordpress.com/?p=975</guid>
		<description><![CDATA[Next week, I&#8217;ll be presenting on SQL Server Developer Tools (SSDT) at two SQL Server User Groups. Will I see you there? NJ SQL Server User Group (9/20) &#8211; http://njsql.org NYC SQL Server User Group (9/22) &#8211; http://nycsqlusergroup.com If you haven&#8217;t already heard, SSDT is the newest SQL Server development environment in Visual Studio 2010, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=975&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Next week, I&#8217;ll be presenting on SQL Server Developer Tools (SSDT) at two SQL Server User Groups. Will I see you there?</p>
<ul>
<li>NJ SQL Server User Group (9/20) &#8211; <a target="_blank" href="http://njsql.org">http://njsql.org</a></li>
<li>NYC SQL Server User Group (9/22) &#8211; <a target="_blank" href="http://nycsqlusergroup.com">http://nycsqlusergroup.com</a></li>
</ul>
<p>If you haven&#8217;t already heard, SSDT is the newest SQL Server development environment in Visual Studio 2010, released as part of SQL Server 2012 (codename &#8220;Denali&#8221;). You can download the current CTP3, but Juneau is not included with the Denali CTP3 bits. Instead, it&#8217;s a separate download via the Web Platform Installer at: <a title="http://www.microsoft.com/web/gallery/install.aspx?appid=JUNEAU10" href="http://www.microsoft.com/web/gallery/install.aspx?appid=JUNEAU10" target="_blank">http://www.microsoft.com/web/gallery/install.aspx?appid=JUNEAU10.</a></p>
<p>You can get a primer on SSDT by <a target="_blank" href="http://bit.ly/lenniblog_SSDT">reading my earlier introductory blog post</a>. Hopefully that inspires you to come meet me in NJ or NYC next week to get an up-close look at SSDT with lots of demos. Session abstract below. Hope to see you!</p>
<blockquote><p><strong>Introducing SQL Server Developer Tools (codename “Juneau”)</strong></p>
<p>With the upcoming release of SQL Server 2012 (codename &#8220;Denali&#8221;), SQL Server Developer Tools (SSDT, codename &#8220;Juneau&#8221;) will serve as your primary development environment for building applications with SQL Server. While SQL Server Management Studio (SSMS) continues to serve as the primary tool for database administrators, SSDT represents a brand new experience. SSDT plugs in to Visual Studio and provides a new SQL Server node in Server Explorer for connected development of on-premises or cloud databases, and also provides a new database project type for offline development.</p>
<p>With SSDT, developers can finally enjoy building applications without constantly switching between Visual Studio and SSMS. In this session, Lenni will demonstrate how SSDT can be used to develop for (and deploy to) on-premise and SQL Azure databases. In addition to replicating most of the functionality found in SSMS, you will learn how to use features such as code navigation, IntelliSense, and refactoring with your database model-indispensable tools previously available only for traditional application development in Visual Studio. We&#8217;ll also cover the new declarative model that allows you to design databases offline and under source control right from within your solution in Visual Studio. Don&#8217;t miss out on this demo-centric information-packed session on the next generation of database development tools for SQL Server!</p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lennilobel.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lennilobel.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lennilobel.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lennilobel.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lennilobel.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lennilobel.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lennilobel.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lennilobel.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lennilobel.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lennilobel.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lennilobel.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lennilobel.wordpress.com/975/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lennilobel.wordpress.com/975/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lennilobel.wordpress.com/975/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lennilobel.wordpress.com&amp;blog=6063141&amp;post=975&amp;subd=lennilobel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lennilobel.wordpress.com/2011/09/13/community-service-week/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e98e16e27fd8ae3e079834b881c74f72?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lennilobel</media:title>
		</media:content>
	</item>
	</channel>
</rss>
