T-SQL: Simple Changes That Go a Long Way

Slides:



Advertisements
Similar presentations
DB glossary (focus on typical SQL RDBMS, not XQuery or SPARQL)
Advertisements

1 Query-by-Example (QBE). 2 v A “GUI” for expressing queries. –Based on the Domain Relational Calulus (DRC)! –Actually invented before GUIs. –Very convenient.
Concepts of Database Management Seventh Edition
Midterm Review Lecture 14b. 14 Lectures So Far 1.Introduction 2.The Relational Model 3.Disks and Files 4.Relational Algebra 5.File Org, Indexes 6.Relational.
SQL Basics. SQL SQL (Structured Query Language) is a special-purpose programming language designed from managing data in relational database management.
Version 1.0. MCAD MCSD MCPD Enterprise SQL MCTS MCT Software/Web Development Consultant Cryptography/Digital Signature Consultant SQL Server 2005/2008R2/2012.
ADVANCE T-SQL: WINDOW FUNCTIONS Rahman Wehelie 7/16/2013 ITC 226.
1 Chapter 7 Query-By-Example by Monica Chan CS157B Professor Lee.
 Continue queries ◦ You completed two tutorials with step-by-step instructions for creating queries in MS Access. ◦ Now must apply knowledge and skills.
04 | Grouping and Aggregating Data Brian Alderman | MCT, CEO / Founder of MicroTechPoint Tobias Ternstrom | Microsoft SQL Server Program Manager.
By: Matt Batalon, MCITP  Another form of temporary storage that can be queried or joined against, much like a table variable, temp.
Using Special Operators (LIKE and IN)
Lecture 8 Creating Stored Functions. Objectives  After completing this lesson, you should be able to do the following:  What is Function?  Types of.
 Agenda 2/20/13 o Review quiz, answer questions o Review database design exercises from 2/13 o Create relationships through “Lookup tables” o Discuss.
Mark Inman U.S. Navy (Naval Sea Logistics Center) Session #213 Analytic SQL for Beginners.
What’s New In Denali - TSQL David Ballantyne. Who am I Kent.Net/SqlServer.
T-SQL: Simple Changes That Go a Long Way DAVE ingeniousSQL.com linkedin.com/in/ingenioussql.
More Windowing Functions KEVIN MCCARTY. What are Windowing Functions Again? Introduced in SQL Server 2005 (SQL 2003 Standard) Used to provide operations.
In this session, you will learn to: Use functions to customize the result set Summarize and group data Objectives.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
IS201 Agenda: 09/19  Modify contents of the database.  Discuss queries: Turning data stored in a database into information for decision making.  Create.
05 | SET Operators, Windows Functions, and Grouping Brian Alderman | MCT, CEO / Founder of MicroTechPoint Tobias Ternstrom | Microsoft SQL Server Program.
Random Query Generator for Hive November 2015 Hive Contributor Meetup Szehon Ho.
SQL. Originally developed by IBM Standardized in 80’s by ANSI and ISO Language to access relational database and English-like non-procedural Predominant.
SQL Query Analyzer. Graphical tool that allows you to:  Create queries and other SQL scripts and execute them against SQL Server databases. (Query window)
Background Lots of Demos(That’s it.)
Sofia, Bulgaria | 9-10 October SQL Querying Tips & Techniques Richard Campbell.
A Glance at the Window Functions. Window Functions Introduced in SQL 2005 Enhanced in SQL 2012 So-called because they operate on a defined portion of.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Scripting Just Enough SSIS to be Dangerous. 6/13/2015 Visit the Sponsor tables to enter their end of day raffles. Turn in your completed Event Evaluation.
6/13/2015 Visit the Sponsor tables to enter their end of day raffles. Turn in your completed Event Evaluation form at the end of the day in the Registration.
Eugene Meidinger Intermediate Querying: Going Beyond Select
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Advanced SQL.
T-SQL Power! Windows That Open Doors Adam
Data Analysis with SQL Window Functions Adam McDonald IT Architect / Senior SQL Developer Smith Travel
SQL Server Statistics and its relationship with Query Optimizer
Using Common Table Expressions
Structured Query Language
Visual Studio Database Tools (aka SQL Server Data Tools)
An Refresher and How-To Profile Data using SQL
Relational Database Design
Indexing Goals: Store large files Support multiple search keys
© 2016, Mike Murach & Associates, Inc.
PEL Vs MDX By Jeremy Kashel TVP, 17th July 2008
T-SQL: Simple Changes That Go a Long Way
T-SQL: Simple Changes That Go a Long Way
Data Analysis with SQL Window Functions
Using Window Ranking, Offset, and Aggregate Functions
Using Indexed Views & Computed Columns for Performance !
SQL Data Modification Statements.
WINDOW FUNCTIONS ARE YOUR FRIENDS Dejan
WINDOW FUNCTIONS ARE YOUR FRIENDS Dejan
Writing Better Queries with Window Functions
Visual Studio Database Tools (aka SQL Server Data Tools)
Chapter 4 Summary Query.
Access: SQL Participation Project
Transact SQL Performance Tips
Introduction to Window Functions
T-SQL gotchas and power-ups
C1. SQL BAsic.
Data Analysis with SQL Window Functions
Introduction to T-sql Window functionS
SQL Aggregation.
Contents Preface I Introduction Lesson Objectives I-2
Partition Switching Joe Tempel.
Build on-the-fly reporting with Dynamic SQL
Introduction to SQL Server and the Structure Query Language
Intermediate Query Structure and Development
Just Enough SSIS Scripting to be Dangerous.
Presentation transcript:

T-SQL: Simple Changes That Go a Long Way DAVE VALENTINE @ingeniousSQL ingeniousSQL.com linkedin.com/in/ingenioussql

Agenda OUTPUT INTO Table Valued Parameter Window Functions Common Table Expressions COALESCE & ISNULL

Understand the Problem Before You Fix Create the Problem

About Dave… MCP MCSA: SQL Server 2012 Database / BI Developer Adjunct Professor @IngeniousSQL Dave.Valentine@IngeniousSQL.com IngeniousSQL.com

OUTPUT INSERT, UPDATE, DELETE, MERGE @@IDENTITY SCOPE_IDENTITY IDENT_CURRENT INSERTED.* and DELETED.* http://technet.microsoft.com/en-us/library/ms177564.aspx

INTO INTO <New Table> Debugging Table Definitions TVP and Table Variables Indexes, Triggers and Constraints Identities https://technet.microsoft.com/en-us/library/ms188029.aspx

Table Valued Parameter Easily store and transfer rows of data User Defined Table Type UNIQUE and PRIMARY KEY Constraints No indexing No statistics Read only as procedure parameters http://technet.microsoft.com/en-us/library/bb510489.aspx

T-SQL Window Functions Ranking RANK, ROW_NUMBER, NTILE, DENSE_RANK http://technet.microsoft.com/en-us/library/ms189798.aspx Aggregate AVG, MIN, SUM, COUNT, STDEV, VAR, MAX http://technet.microsoft.com/en-us/library/ms173454.aspx Analytic LEAD, FIRST_VALUE, LAG, LAST_VALUE http://technet.microsoft.com/en-us/library/hh213234.aspx

Common Table Expressions CTE Simplify query syntax Multiple reference Recursive queries VIEW alternative http://technet.microsoft.com/en-us/library/ms190766(v=sql.105).aspx

COALESCE & ISNULL COALESCE (expression [,…n]) ISNULL (expression, expression) Data Types Optional Parameter CSV https://technet.microsoft.com/en-us/library/ms190349.aspx https://technet.microsoft.com/en-us/library/aa933210.aspx

T-SQL Simple Changes Demo

Summary INTO OUTPUT Table Valued Parameter Window Functions Common Table Expressions COALESCE & ISNULL

Questions DAVE VALENTINE @ingeniousSQL ingeniousSQL.com linkedin.com/in/ingenioussql