Search results matching tags 'SQL Server 2012', 'for xml path', and 'Windowing functions'http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&tag=SQL+Server+2012,for+xml+path,Windowing+functions&orTags=0Search results matching tags 'SQL Server 2012', 'for xml path', and 'Windowing functions'en-USCommunityServer 2.1 SP2 (Build: 61129.1)Connect Digest : 2012-03-06http://sqlblog.com/blogs/aaron_bertrand/archive/2012/03/06/connect-digest-2012-03-06.aspxTue, 06 Mar 2012 13:57:00 GMT21093a07-8b3d-42db-8cbf-3350fcbf5496:42114AaronBertrand<p>This time around, I've got five wish list items for T-SQL / DDL, and then one bonus - a parallelism bug. My thinking on the former is that, since we are either about to start (or are just finishing) locking down the code for SQL Server 2012, this is the first moment where some of these suggestions can be seriously considered without the "but we're about to ship" excuse. :-) The last one is just an incorrect results bug that needs to be fixed. I'll start with the T-SQL / DDL wishes:<br><br></p>
<p><font size="4">Ordered Set Functions</font></p>
<p>For a while I've been pretty vocal about getting grouped concatenation into SQL Server - functionality that exists in MySQL (<a href="http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat" title="http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat" target="_blank">GROUP_CONCAT</a>) and more recently added to Oracle 11gR2 (<a href="http://docs.oracle.com/cd/E14072_01/server.112/e10592/functions087.htm" title="http://docs.oracle.com/cd/E14072_01/server.112/e10592/functions087.htm" target="_blank">LISTAGG</a>). (And here I thought we were the only pencil-necks using an R2 moniker.) I've often promoted <a href="http://connect.microsoft.com/SQLServer/feedback/details/247118/sql-needs-version-of-mysql-group-concat-function" title="http://connect.microsoft.com/SQLServer/feedback/details/247118/sql-needs-version-of-mysql-group-concat-function" target="_blank">this Connect item</a> when the question comes up on forums or #sqlhelp. This can be solved by a grander implementation - ordered set functions. This comes directly from the standard and supports grouped concatenation (with predictable ordering, unlike many of the workarounds that exist today, such as FOR XML PATH), and a slew of other functionality. The item you should vote for is one that Itzik Ben-Gan just raised this week (and please see <a href="http://tsql.solidq.com/OSF.doc" title="http://tsql.solidq.com/OSF.doc" target="_blank">this document for more in-depth background</a>):<br></p>
<blockquote>
<p><a href="http://connect.microsoft.com/SQLServer/feedback/details/728969/feature-request-ordered-set-functions-within-group-clause" title="http://connect.microsoft.com/SQLServer/feedback/details/728969/feature-request-ordered-set-functions-within-group-clause" target="_blank">Connect #728969</a><br></p>
</blockquote>
<p><br><font size="4">Create or Replace</font></p>
<p>I'm pretty sure I've pimped this one before, but in the interest of driving up items that might make the T-SQL / DDL feature list for the *next* version of SQL Server... we should have the ability to specify in the DDL that we want to create this thing if it doesn't exist, and alter if it does. This avoids the need to re-script permissions, worry about breaking existing dependencies, or build complicated batch logic with a stub create, dynamic SQL, etc. I would gladly take this for simple modules only (procedures, triggers, functions, non-indexed views) as the logic around completely re-designing, say, a table can quickly become more complex.<br></p>
<blockquote>
<p><a href="http://connect.microsoft.com/SQLServer/feedback/details/127219/create-or-replace" title="http://connect.microsoft.com/SQLServer/feedback/details/127219/create-or-replace" target="_blank">Connect #127219</a><br></p>
</blockquote>
<p><br><font size="4">Native Regular Expression Support </font><br></p>
<p>I would love to see RegEx as a first class citizen, and at least in V1 don't expect this to be fully optimized the way LIKE can be. I just get so sick of writing complex and wordy expressions using PATINDEX / SUBSTRING / STUFF / REVERSE while switching between 0-based and 1-based in my head. And I . Since other CLR functionality is slowly making its way into the top T-SQL tier (spatial, FORMAT(), TRY_PARSE(), etc), I think it's high time we can perform RegEx as well without each of us having to write our own complicated assemblies, deploying and maintaining them, all that assuming we can assure the boss or the IT guys that it's ok to use CLR.</p>
<blockquote>
<p><a href="http://connect.microsoft.com/SQLServer/feedback/details/261342/regex-functionality-in-pattern-matching" title="http://connect.microsoft.com/SQLServer/feedback/details/261342/regex-functionality-in-pattern-matching" target="_blank">Connect #261342</a><br></p>
</blockquote>
<p><br><font size="4">Create Table As</font></p>
<p>It would be really nice to have DDL that just says "create a table, but make it a copy of that other table." Today it is easy enough to do this using the tools but to do it in an automated way of any kind is foolhardy - the complexity of the code to generate a CREATE TABLE statement when anything complex is involved can be astounding - consider dependencies, constraints, keys, permissions, triggers, computed columns, indexes, etc. Some folks recommend PowerShell for this but I just think you are trading a different syntax for the same complex code. </p>
<blockquote>
<p><a href="http://connect.microsoft.com/SQLServer/feedback/details/124506/please-add-support-for-complex-data-types-in-t-sql-especially-ability-to-derive-types-from-existing-database-objects-tables-views-and-columns" title="http://connect.microsoft.com/SQLServer/feedback/details/124506/please-add-support-for-complex-data-types-in-t-sql-especially-ability-to-derive-types-from-existing-database-objects-tables-views-and-columns" target="_blank">Connect #124506</a><br><br></p>
</blockquote>
<font size="4">Dynamic Pivot</font>
<p>The PIVOT and UNPIVOT commands as they exist today expect that you know all of the potential values up front. What if you are feeding a report that is more than happy to accept as many columns as you're willing to provide? What ends up happening is we use really ugly workarounds with dynamic SQL after scanning the table and seeing all the potential pivot values (year-month combinations, let's say) that may be represented. I'd like to see this be a little more reactive to the data returned by the query, though it does step into the land of unstructured data at least a little bit...</p>
<blockquote><a href="http://connect.microsoft.com/SQLServer/feedback/details/127071/pivot" title="http://connect.microsoft.com/SQLServer/feedback/details/127071/pivot" target="_blank">Connect #127071</a></blockquote>
<p><br><i>...and one of these things is not like the others...</i></p>
<p><br><font size="4">Another parallelism bug</font></p>
<p>While at least one of the related bugs has recently been fixed, I've previously talked about a few <a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/03/21/six-reasons-you-should-be-nervous-about-parallelism.aspx" title="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/03/21/six-reasons-you-should-be-nervous-about-parallelism.aspx" target="_blank">potential perils of parallelism</a>
(say that three times fast!). Last week at the MVP Summit I encountered
an unfortunate scenario in SQL Server 2012, where incorrect and in fact
unpredictable results can come out of using SUM() OVER() with the new
windowing functions when combined with parallelism. There are some
decent workarounds but they're not very intuitive (and it may be
difficult to notice that you're affected). <br></p><blockquote><a href="http://connect.microsoft.com/SQLServer/feedback/details/728932/parallelism-bug-with-sum-over-and-range" title="http://connect.microsoft.com/SQLServer/feedback/details/728932/parallelism-bug-with-sum-over-and-range" target="_blank">Connect #728932</a> <br>&nbsp;<br></blockquote>