Ottimizzazione

Usare json su SQLServer 2005, 2008, 2012 e 2014 .. è possibile!

Vedere il supporto nativo di JSON su SQLServer 2016 (e anche su Azure SQLDatabase) mi ha fatto pensare che magari era possibile averlo in forma semplificata anche su versioni precedenti.

Tutto è nato dalla necessità di gestire un flusso di dati con una Stored Procedure in arrivo da una WebAPI. Inizialmente la WebAPI, dopo aver fatto gli opportuni controlli logici di validità, deserializzava il flusso per poi formattare una stringa da passare alla Stored Procedure. La gestione del parametro in ingresso alla SP come TABLE non sembrava possibile utilizzando EF6, quindi si è optato di mantenere la SP nello stato originale, ovvero con la stringa e altri parametri per i caratteri separatori.

Building Your T-SQL Tool Kit: Window Function Fundamentals

Sergio Govoni

Sul canale SQLPASS TV è stata pubblicata la sessione Building Your T-SQL Tool Kit: Window Function Fundamentals tenuta da Christina E. Leo (@christinaleo) durante lo scorso PASS Summit 2013.

Abstract

Have you pulled a script to identify duplicates from a blog post but couldn’t quite get it to work because you weren’t sure what that ROW_NUMBER() function was doing? Maybe you heard talk about creating running totals without using subqueries, but you got frustrated when the groups weren’t totaling correctly. Or maybe, you’ve never even heard of window functions. All are good reasons to attend this all-demo session, which demystifies this versatile T-SQL tool. First, we’ll break apart the OVER clause, the key to understanding how window functions work. Then we’ll expand on each group of functions that can use the OVER clause: ranking, aggregate, and analytic functions. Finally, we’ll look at real scenarios where this tool works and talk about performance considerations. When you leave, you’ll have the fundamentals you need to fully develop your mastery of window functions.

New book: Microsoft SQL Server 2012 High-Performance T-SQL Using Window Functions

Sergio Govoni

Su MS Press Blog è stata annunciata la pubblicazione del nuovo libro Microsoft SQL Server 2012 High-Performance T-SQL Using Window Functions; l’autore non ha bisogno di presentazioni, è il grande Itzik Ben-Gan.

Il testo è dedicato alle funzioni di windowing che si applicano tipicamente al sotto-insieme di dati (finestra) determinato dalla clausola OVER, introdotta con SQL Server 2005 e ampiamente estesa in SQL Server 2012. Il linguaggio T-SQL non è solo SELECT, INSERT, UPDATE, DELETE e MERGE; chi ha la possibilità di studiarlo si accorge ben presto di quanto sia ricco di statement set-based e di quanto sia importante avere un linguaggio dichiarativo per scrivere query!