T-Sql

PASS Summit Unite 2009

Davide Mauri

L’annuale summit del PASS - Professional Association of SQL Server users, si terrà ancora una volta a Seattle. Il summit è la più importante conferenza su SQL Server a livello mondiale, alla quale partecipano solamente i migliori speaker, offrendo un’opportunità di formazione e di networking assolutamente unica.

Con 168 sessioni suddivise in 5 track - Database Administration, Database and Application Development, BI Platform Architecture, BI Information Delivery, and Professional Development - questa conferenza è indispensabile per tutti coloro che vogliono migliorare e rendere più efficiente il proprio lavoro con SQL Server e tutte le tecnologie ad esso legate, capire in che modo si evolverà il futuro con la release della versione R2, fare networking per espandere la proprio rete di conoscenze e - perchè no - passare una settimana di full-immersion in una città sempre bella come Seattle.

Ten Common SQL Programming Mistakes

Davide Mauri

Articolo che elenca e spiega come evitare i 10 più comuni errori che si fanno con T-SQL, che, secondo l’autore, sono i seguenti:

  1. NULLs and the NOT IN predicate
  2. Functions on indexed columns in predicates
  3. Incorrect subquery column
  4. Data type mismatch in predicates
  5. Predicate evaluation order
  6. Outer joins and placement of predicates
  7. Subqueries that return more than one value
  8. Use of SELECT *
  9. Scalar user-defined functions
  10. Overuse of cursors

Articolo veramente interessante, di breve lettura ma di grande utilità.

Verificare la presenza di indici identici / duplicati

Davide Mauri

Qual è il rischio in cui si può incorrere quando un progetto viene sviluppato da più persone, ovvero quando un database viene modellato da più mani?

Creare un indice che esiste già! :-(

SQL Server non fa nulla per venirci in aiuto o, almeno, non fa nulla in automatico.
Con questo script è possibile ottenere una lista degli indici identici / duplicati.

;WITH tIndex AS (
SELECT    object_id AS id ,    index_id AS indid ,    type,     name ,    (        SELECT            colid as colPosition        FROM sys.sysindexkeys        WHERE id = I.object_id AND indid = I.index_id            AND keyno > 0        FOR XML PATH      ) AS cols ,    (        SELECT includedCol FROM        (            SELECT                CASE keyno WHEN 0 THEN colid ELSE NULL END AS includedCol            FROM sys.sysindexkeys            WHERE id = I.object_id AND indid = I.index_id        ) T0        order by includedCol        FOR XML PATH    ) AS inc
FROM sys.indexes AS I )
SELECT    object_schema_name ( T1.id ) + ‘.’ + object_name ( T1.id ) as tableName,    T1.name AS indexName,    T2.name AS duplicateIndex,    S.used_page_count * 8 indexSizeKB
FROM tIndex AS T1
JOIN tIndex AS T2 ON     T1.type = T2.type AND    T1.id = T2.id AND     T1.indid < T2.indid AND    T1.cols = T2.cols AND    T1.inc = T2.inc
JOIN sys.dm_db_partition_stats  AS S ON    S.[object_id] = T2.id AND S.index_id = T2.indId
ORDER BY object_schema_name ( T1.id ) + ‘.’ + object_name ( T1.id ), T1.name
go

Quali libri mi consigliate per imparare a sviluppare con SQL Sever 2005/2008?

Davide Mauri

Quali sono i libri più efficaci per imparare a sviluppare con SQL Server, utilizzato T-SQL, SQLXML e SQLCLR?

Senza alcun dubbio i libri della serie “Inside SQL Server”:

**Inside Microsoft® SQL Server® 2008: T-SQL Fundamentals
**http://www.amazon.com/Microsoft%C2%AE-Server%C2%AE-T-SQL-Fundamentals-PRO-Developer/dp/0735626014/ref=pd_bxgy_b_img_c

**Inside Microsoft® SQL Server® 2008: T-SQL Querying
**http://www.amazon.com/gp/product/0735626030

Oltre a questi, molto validi e consigliati sono anche

Pro SQL Server 2008 Relational Database Design and Implementation http://www.amazon.com/Server-Relational-Database-Design-Implementation/dp/143020866X/ref=sr_1_1?ie=UTF8&s=books&qid=1240674199&sr=1-1

**Microsoft SQL Server 2008 Bible
**http://www.amazon.com/Microsoft-SQL-Server-2008-Bible/dp/0470257040/ref=sr_1_1?ie=UTF8&s=books&qid=1240674245&sr=1-1