SQL Spackle #1 Jeff Moden 19 May 2011. About Your Speaker Mostly Self Trained Started with SQL Server in 1995 More than 25,000 posts on SQLServerCentral.com.

Slides:



Advertisements
Similar presentations
Reviewing your Program CS 5010 Program Design Paradigms “Bootcamp” Lesson 2.4 © Mitchell Wand, This work is licensed under a Creative Commons.
Advertisements

P449. p450 Figure 15-1 p451 Figure 15-2 p453 Figure 15-2a p453.
Honors Compilers An Introduction to Grammars Feb 12th 2002.
Tempdb Parasites Jason Hall-Dir. of Client SQL Sentry Blog-jasonhall.blogs.sqlsentry.net.
PL/SQL Bulk Collections in Oracle 9i and 10g Kent Crotty Burleson Consulting October 13, 2006.
How to Read a Scientific Journal Article. Abstract Gives a basic overview of what the whole paper is going to be about. Begins with a sentence or so of.
MySql In Action Step by step method to create your own database.
Automation Testing- QTP Rajesh Charles Batch No: Date: jan
Cursor and Exception Handling By Nidhi Bhatnagar.
T-SQL : Bad Habits to Kick Aaron Bertrand SQL Sentry, Inc.
1 Accelerated Web Development Course JavaScript and Client side programming Day 2 Rich Roth On The Net
Revision on Triggers and Cursors. Walk through of exam type question. Question 1. A trigger is required to automatically update the number of rooms available.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
(Chapter 10 continued) Our examples feature MySQL as the database engine. It's open source and free. It's fully featured. And it's platform independent.
Lecture Note 10: Simple Database Techniques. Introduction –Database System –Access, SQL Server and others. –Microsoft Access - Interacting with this databases.
Templates An introduction. Simple Template Functions template T max(T x, T y) { if (x > y) { return x; } else { return y; } } int main(void) { int x =
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
Web User Controls This presentation will cover the basics of defining, creating and using a web user control. Presented to Twin Cities.NET user group By.
Stored Procedure. Objective At the end of the session you will be able to know :  What are Stored Procedures?  Create a Stored Procedure  Execute a.
PHP Form Introduction Getting User Information Text Input.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Using SQL in PL/SQL Oracle Database PL/SQL 10g Programming Chapter 4.
ICS3U_FileIO.ppt File Input/Output (I/O)‏ ICS3U_FileIO.ppt File I/O Declare a file object File myFile = new File("billy.txt"); a file object whose name.
Programming Fundamentals. Topics to be covered Today Recursion Inline Functions Scope and Storage Class A simple class Constructor Destructor.
Oracle PL/SQL Loops Please use speaker notes for additional information!
Week 6 - Friday.  What did we talk about last time?  Loop examples.
DITA TOPICS - ADVANCED. Session Results Topic Types Review Format/Layout Separated from Content DITA Concept Elements Using DITA Concept Elements - Advanced.
RETRIEVE A NO. OF ROWS ¦ Declare a cursor ¦ Open the cursor ¦ Fetch rows of data ¦ Stop fetching rows ¦ Close the cursor.
Lab 2 Writing PL/SQL Blocks CISB514 Advanced Database Systems.
Thinking in Sets and SQL Query Logical Processing.
National Diploma Unit 4 Introduction to Software Development Procedures and Functions.
There’s a particular style to it… Rob Hatton
SQL Saturday Pittsburgh So you want to be a DBA What is a DBA? Michael John Ed Wagner SQL Saturday Pittsburgh October 3rd 2015.
Database Administration for the Non-DBA Denny Cherry twitter.com/mrdenny.
Automation Testing- QTP Rajesh Charles Batch No: Date: jan
Cleveland SQL Saturday Catch-All or Sometimes Queries
The Tally Table and Pseudo Cursors
Data Virtualization Tutorial: Introduction to SQL Script
SA Education Watch me first.
Introduction to PL/SQL Programing
Reviewing your Program
T-SQL Coding Techniques Are you playing with fire?
The "Numbers" or "Tally" Table:
More on Procedures (Internal/Local procedures)
The Nitty-Gritty of Database Backups
Error Handling Summary of the next few pages: Error Handling Cursors.
Introduction to SQL Server Management for the Non-DBA
Cookies BIS1523 – Lecture 23.
SQL Server May Let You Do It, But it Doesn’t Mean You Should
Introduction to Execution Plans
TSQL Coding Techniques
Dynamic SQL for the DBA by Jeff Moden
Advanced PL/SQL Programing
The Killing Cursors Cyndi Johnson
Topic 7 Nested Loops Case Study
Tally Ho! -- Explore the Varied Uses of Tally Tables
The 5 Hidden Performance Gems
Working with Long Strings by Jeff Moden
Please thank our sponsors!
Ensuring a Remote Server is Available
Tally Function with Error Checking by Jeff Moden
Cyndi Johnson Senior Software Engineer at AdvancedMD Killing Cursors.
Introduction to Execution Plans
Title of Study Presenter names Major department names
More and Still More on Procedures and Functions
Cyndi Johnson Senior Software Engineer at AdvancedMD Killing Cursors.
Introduction to Execution Plans
Introduction to Execution Plans
Handling Data Errors in a Dataflow Task
Presentation transcript:

SQL Spackle #1 Jeff Moden 19 May 2011

About Your Speaker Mostly Self Trained Started with SQL Server in 1995 More than 25,000 posts on SQLServerCentral.com (some are actually useful) 22 Articles on SQLServerCentral.com – Moden/80567/ SQL Server MVP since 2008 Coined the phrase “RBAR” 2 Sessions at PASS 2010 SQL Server Saturday #60 – Brunswick, OH

Agenda Introduction to “Pseudo Cursors” –What they are –Declarative Code –Procedural Code –Examples The Calendar Table –What it is –How to build it –Usage examples

Introduction To “Pseudo Cursors”

Behind the Scenes… What IS SQL Server Really? –It’s nothing more than a very sophisticated file system. What IS a SELECT? –It’s nothing more than “declarative” code that loops through a part of a file identified as a “table”. –It does almost like the code you’d write… find a row, read a row, process a row, loop until done. –It LOOPs in the background so you don’t have to write loops like a front-end Developer.

“Declarative” Code You tell it what you want done SQL Server figures out how to do it. “Set Based” code is where you allow or even help SQL Server do the best job that it can do. It works with more than one row at a time or in “sets” of rows.

“Procedural” Code Easy name to remember because you tell SQL Server how to “proceed” every step of the way. Consists of explicit Loops Consists of “hidden” RBAR such as recursive CTE’s and recursive functions. Is usually quite slow because SQL Server can’t do what it’s supposed to

“Pseudo Cursor” Examples

The “Calendar” Table

What A Calendar Table Is A “Helper” Table Auxiliary Table of Dates A special kind of “Pseudo Cursor” Pre-populated with date related info Use to replace Cursors, While loops, and other complicated code.

Building the “Calendar” Table

“Calendar” Table Code Examples

Grouping “Islands of Dates”