100% found this document useful (1 vote)
11 views

SQL Server Data Automation Through Frameworks: Building Metadata-Driven Frameworks with T-SQL, SSIS, and Azure Data Factory Andy Leonard instant download

The document discusses SQL Server Data Automation through frameworks, focusing on building metadata-driven frameworks using T-SQL, SSIS, and Azure Data Factory. It includes various chapters detailing stored procedure-based frameworks, automation techniques, and the integration of SSIS with Azure services. Additionally, it provides practical examples and resources for readers to implement these frameworks effectively.

Uploaded by

bltvzbxgzg265
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
11 views

SQL Server Data Automation Through Frameworks: Building Metadata-Driven Frameworks with T-SQL, SSIS, and Azure Data Factory Andy Leonard instant download

The document discusses SQL Server Data Automation through frameworks, focusing on building metadata-driven frameworks using T-SQL, SSIS, and Azure Data Factory. It includes various chapters detailing stored procedure-based frameworks, automation techniques, and the integration of SSIS with Azure services. Additionally, it provides practical examples and resources for readers to implement these frameworks effectively.

Uploaded by

bltvzbxgzg265
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

SQL Server Data Automation Through Frameworks:

Building Metadata-Driven Frameworks with T-SQL,


SSIS, and Azure Data Factory Andy Leonard
download
https://textbookfull.com/product/sql-server-data-automation-
through-frameworks-building-metadata-driven-frameworks-with-t-
sql-ssis-and-azure-data-factory-andy-leonard/

Download full version ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

SQL Server Execution Plans For SQL Server 2008 through


to 2017 and Azure SQL Database 3rd Edition Grant
Fritchey

https://textbookfull.com/product/sql-server-execution-plans-for-
sql-server-2008-through-to-2017-and-azure-sql-database-3rd-
edition-grant-fritchey/

Building Custom Tasks for SQL Server Integration


Services: The Power of .NET for ETL for SQL Server 2019
and Beyond 2nd Edition Andy Leonard

https://textbookfull.com/product/building-custom-tasks-for-sql-
server-integration-services-the-power-of-net-for-etl-for-sql-
server-2019-and-beyond-2nd-edition-andy-leonard/

Building Custom Tasks for SQL Server Integration


Services The Power of NET for ETL for SQL Server 2019
and Beyond Second Edition Andy Leonard

https://textbookfull.com/product/building-custom-tasks-for-sql-
server-integration-services-the-power-of-net-for-etl-for-sql-
server-2019-and-beyond-second-edition-andy-leonard/

Biota Grow 2C gather 2C cook Loucas

https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-
loucas/
Quick Start Guide to Azure Data Factory Azure Data Lake
Server and Azure Data Warehouse 1st Edition Mark
Beckner

https://textbookfull.com/product/quick-start-guide-to-azure-data-
factory-azure-data-lake-server-and-azure-data-warehouse-1st-
edition-mark-beckner/

Data Integration Life Cycle Management with SSIS: A


Short Introduction by Example 1st Edition Andy Leonard

https://textbookfull.com/product/data-integration-life-cycle-
management-with-ssis-a-short-introduction-by-example-1st-edition-
andy-leonard/

SQL Server Big Data Clusters : Data Virtualization,


Data Lake, and AI Platform Benjamin Weissman

https://textbookfull.com/product/sql-server-big-data-clusters-
data-virtualization-data-lake-and-ai-platform-benjamin-weissman/

Azure SQL Revealed: A Guide to the Cloud for SQL Server


Professionals Bob Ward

https://textbookfull.com/product/azure-sql-revealed-a-guide-to-
the-cloud-for-sql-server-professionals-bob-ward/

Azure SQL Revealed: A Guide to the Cloud for SQL Server


Professionals 1st Edition Bob Ward

https://textbookfull.com/product/azure-sql-revealed-a-guide-to-
the-cloud-for-sql-server-professionals-1st-edition-bob-ward/
SQL Server Data
Automation
Through
Frameworks
Building Metadata-Driven Frameworks with
T-SQL, SSIS, and Azure Data Factory

Andy Leonard
Kent Bradshaw
SQL Server Data
Automation Through
Frameworks
Building Metadata-Driven
Frameworks with T-SQL, SSIS,
and Azure Data Factory

Andy Leonard
Kent Bradshaw
SQL Server Data Automation Through Frameworks: Building Metadata-Driven
Frameworks with T-SQL, SSIS, and Azure Data Factory
Andy Leonard Kent Bradshaw
Farmville, VA, USA Providence Forge, VA, USA

ISBN-13 (pbk): 978-1-4842-6212-2 ISBN-13 (electronic): 978-1-4842-6213-9


https://doi.org/10.1007/978-1-4842-6213-9

Copyright © 2020 by Andy Leonard, Kent Bradshaw


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Jonathan Gennick
Development Editor: Laura Berendson
Coordinating Editor: Jill Balzano
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street,
6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-
sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member
(owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a
Delaware corporation.
For information on translations, please e-mail [email protected]; for reprint,
paperback, or audio rights, please e-mail [email protected].
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/9781484262122. For more
detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
For Christy
—Andy

For Ann
—Kent
Table of Contents
About the Authors���������������������������������������������������������������������������������������������������� xi

About the Technical Reviewer������������������������������������������������������������������������������� xiii


Acknowledgments���������������������������������������������������������������������������������������������������xv

Introduction�����������������������������������������������������������������������������������������������������������xvii

Part I: Stored Procedure-Based Database Frameworks������������������������������������������� 1

Chapter 1: Stored Procedures 101��������������������������������������������������������������������������� 3


The Need for a Framework����������������������������������������������������������������������������������������������������������� 3
Demonstration of a Framework���������������������������������������������������������������������������������������������������� 4
An Example Schema���������������������������������������������������������������������������������������������������������������� 5
The Daily Process�������������������������������������������������������������������������������������������������������������������� 6
Executing the Daily Process�������������������������������������������������������������������������������������������������� 12
Including a Monthly Process������������������������������������������������������������������������������������������������� 12
Summary������������������������������������������������������������������������������������������������������������������������������������ 18

Chapter 2: Automation with Stored Procedures����������������������������������������������������� 19


A Daily Process Controller����������������������������������������������������������������������������������������������������������� 19
Monthly Process Controller��������������������������������������������������������������������������������������������������������� 23
Summary������������������������������������������������������������������������������������������������������������������������������������ 26

Chapter 3: Stored Procedure Orchestrators����������������������������������������������������������� 27


The Orchestrator������������������������������������������������������������������������������������������������������������������������� 27
A Quick Process Overview���������������������������������������������������������������������������������������������������������� 31
A Look at Troubleshooting Issues������������������������������������������������������������������������������������������������ 31
Summary������������������������������������������������������������������������������������������������������������������������������������ 32

v
Table of Contents

Chapter 4: A Stored Procedure–Based Metadata-Driven Framework�������������������� 33


Building the Metadata����������������������������������������������������������������������������������������������������������������� 33
Metadata-Ready Controllers������������������������������������������������������������������������������������������������������� 40
Metadata-Ready Orchestrator����������������������������������������������������������������������������������������������������� 47
Troubleshooting with Metadata�������������������������������������������������������������������������������������������������� 50
Summary������������������������������������������������������������������������������������������������������������������������������������ 56

Part II: SSIS Frameworks���������������������������������������������������������������������������������������� 57

Chapter 5: A Simple, Custom, File-­Based SSIS Framework������������������������������������ 59


An SSIS Framework, Defined and Designed������������������������������������������������������������������������������� 60
Functionality�������������������������������������������������������������������������������������������������������������������������� 60
Empathy�������������������������������������������������������������������������������������������������������������������������������� 60
Simplicity������������������������������������������������������������������������������������������������������������������������������� 60
Building a File-Based SSIS Framework�������������������������������������������������������������������������������������� 61
Obtain the Code��������������������������������������������������������������������������������������������������������������������� 61
Metadata-Driven Execution Management����������������������������������������������������������������������������� 62
The SSISConfig Database������������������������������������������������������������������������������������������������������ 62
Config Schema���������������������������������������������������������������������������������������������������������������������� 63
The Config.Applications Table������������������������������������������������������������������������������������������������ 65
The Config.Packages Table���������������������������������������������������������������������������������������������������� 67
A Sample SSIS Solution�������������������������������������������������������������������������������������������������������������� 75
Configure Visual Studio 2019 for SSIS Development������������������������������������������������������������� 76
Create the Sample SSIS Solution������������������������������������������������������������������������������������������ 78
SSIS Framework Metadata Management����������������������������������������������������������������������������������� 85
Add an SSIS Application�������������������������������������������������������������������������������������������������������� 85
Add SSIS Packages��������������������������������������������������������������������������������������������������������������� 88
Assign SSIS Application Packages���������������������������������������������������������������������������������������� 91
Conclusion���������������������������������������������������������������������������������������������������������������������������������� 96

vi
Table of Contents

Chapter 6: Framework Execution Engine��������������������������������������������������������������� 97


Create a Parent SSIS Package���������������������������������������������������������������������������������������������������� 97
Log Execution Values������������������������������������������������������������������������������������������������������������������ 98
Retrieve SSIS Application Packages from SSISConfig�������������������������������������������������������������� 104
Iterate Application Packages����������������������������������������������������������������������������������������������������� 120
Log Application Package Values����������������������������������������������������������������������������������������������� 130
Execute Application Packages�������������������������������������������������������������������������������������������������� 135
Log Execution Results��������������������������������������������������������������������������������������������������������������� 150
Conclusion�������������������������������������������������������������������������������������������������������������������������������� 158

Chapter 7: Framework Logging���������������������������������������������������������������������������� 159


Create a Log Schema���������������������������������������������������������������������������������������������������������������� 159
Add Application Instance Logging to Parent.dtsx���������������������������������������������������������������������� 164
Add Application Package Instance Logging to Parent.dtsx������������������������������������������������������� 176
Viewing Execution Report Data������������������������������������������������������������������������������������������������� 191
Configure Fault Tolerance in SSIS Framework Application Metadata��������������������������������������� 197
Conclusion�������������������������������������������������������������������������������������������������������������������������������� 206

Chapter 8: Azure-SSIS Integration Runtime��������������������������������������������������������� 207


Getting Started with Azure�������������������������������������������������������������������������������������������������������� 207
Provisioning an Azure Data Factory������������������������������������������������������������������������������������������ 208
Provisioning Azure Storage������������������������������������������������������������������������������������������������������� 217
Provisioning an Azure-SSIS Integration Runtime for SSIS Package Files��������������������������������� 223
Stopping the Azure-SSIS Integration Runtime�������������������������������������������������������������������������� 236
Conclusion�������������������������������������������������������������������������������������������������������������������������������� 240

Chapter 9: Deploy a Simple, Custom, File-Based Azure-SSIS Framework������������ 241


Provisioning the SSISConfig Database�������������������������������������������������������������������������������������� 241
Deploy the Simple, Custom, File-Based Azure-SSIS Framework���������������������������������������������� 249
Provision an Azure File Share��������������������������������������������������������������������������������������������������� 267
Upload SSIS Packages��������������������������������������������������������������������������������������������������������� 270
Update PackageLocation Values������������������������������������������������������������������������������������������ 272

vii
Table of Contents

Build the SSIS Framework ADF Execution Engine�������������������������������������������������������������������� 273


Retrieve a List of SSIS Packages����������������������������������������������������������������������������������������� 273
Execute the Retrieved SSIS Packages��������������������������������������������������������������������������������� 287
View Test Execution Logs���������������������������������������������������������������������������������������������������� 296
Conclusion�������������������������������������������������������������������������������������������������������������������������������� 299

Chapter 10: Framework Logging in ADF��������������������������������������������������������������� 301


Add the ApplicationName Parameter���������������������������������������������������������������������������������������� 301
A Quick Review of SSIS Framework Applications and Packages���������������������������������������� 302
Add Application Instance Logging��������������������������������������������������������������������������������������������� 303
Modifying the Log.ApplicationInstance Table���������������������������������������������������������������������� 303
Adding the Log.InsertApplicationInstance Stored Procedure���������������������������������������������� 304
Logging Application Instance���������������������������������������������������������������������������������������������� 306
Adding the Log.UpdateApplicationInstanceStatus Stored Procedure���������������������������������� 311
Updating Application Instance��������������������������������������������������������������������������������������������� 312
Let’s Test It!������������������������������������������������������������������������������������������������������������������������� 316
Updating Application Instance on Success�������������������������������������������������������������������������� 317
Adding the ApplicationPackageId Field������������������������������������������������������������������������������� 320
Adding the ApplicationInstanceId Pipeline Variable������������������������������������������������������������� 321
Add the Child Pipeline��������������������������������������������������������������������������������������������������������� 325
Let’s Test It!������������������������������������������������������������������������������������������������������������������������� 333
Add Application Package Instance Logging������������������������������������������������������������������������������ 334
Modifying the Log.ApplicationPackageInstance Table��������������������������������������������������������� 335
Adding the Log.InsertApplicationPackageInstance Stored Procedure��������������������������������� 336
Logging Application Package Instance�������������������������������������������������������������������������������� 338
Adding the Log.UpdateApplicationPackageInstanceStatus Stored Procedure�������������������� 344
Updating Application Package Instance������������������������������������������������������������������������������ 345
Let’s Test It!������������������������������������������������������������������������������������������������������������������������� 348
Updating Application Package Instance on Success����������������������������������������������������������� 350
Conclusion�������������������������������������������������������������������������������������������������������������������������������� 353

viii
Table of Contents

Chapter 11: Fault Tolerance in the ADF Framework��������������������������������������������� 355


A Brief Introduction to Fault Tolerance�������������������������������������������������������������������������������������� 355
Add ADF Managed Identity to Contributor Role������������������������������������������������������������������������� 356
Add Application Package Fault Tolerance��������������������������������������������������������������������������������� 359
About Fail Application on Package Failure�������������������������������������������������������������������������� 359
Implementing Application Package Fault Tolerance������������������������������������������������������������ 359
Checking the Logic�������������������������������������������������������������������������������������������������������������� 362
Implementing the Fault Tolerance Logic������������������������������������������������������������������������������ 363
Let’s Test It!������������������������������������������������������������������������������������������������������������������������� 378
Conclusion�������������������������������������������������������������������������������������������������������������������������������� 383

Index��������������������������������������������������������������������������������������������������������������������� 385

ix
About the Authors
Andy Leonard is Chief Data Engineer at Enterprise Data
& Analytics, creator and Data Philosopher at DILM (Data
Integration Lifecycle Management) Suite, an Azure Data
Factory and SQL Server Integration Services trainer and
consultant, and a BimlHero. He is a SQL Server database and
data warehouse developer, community mentor, engineer,
and farmer. Andy is coauthor of SQL Server Integration
Services Design Patterns, Data Integration Life Cycle
Management with SSIS, and The Biml Book.

Kent Bradshaw is the founder or Tudor Data Solutions,


LLC. With over 40 years of IT experience, he is a SQL
Server database/ETL developer and database architect
with a background in Medicaid claims, public schools,
government, retail, and insurance systems. In 2011,
Kent founded Tudor Data Solutions, LLC, to pursue new
development opportunities which led to his association with
Andy Leonard and Enterprise Data & Analytics. In 2017, Kent
received the MPP certification for Data Science.

xi
About the Technical Reviewer
André van Meulebrouck has a keen interest in functional
programming, especially Haskell and F#.
He also likes data technologies from markup languages
to databases and F# type providers.
He lives in Southern California with his wife “Tweety”,
and is active in athletics: hiking, mountain biking, and
gravity/balance sports like freestyle skating (in-line and ice),
skateboarding, surfing, and sandboarding.
To keep his mind sharp, he does compositional origami, plays classical guitar, and
enjoys music notation software.

xiii
Acknowledgments
This book would not have been possible without the help of Kent Bradshaw, my
coauthor, friend, and brother. This book represents Kent’s first foray into authoring, and
he delivered outstanding work.
Thanks André van Meulebrouck for proofreading, working through the samples, and
providing feedback on the manuscript.
I owe my coworkers at Enterprise Data & Analytics (EntDNA.com) a debt of gratitude
for their encouragement and for covering for me when I stayed up too late trying to
figure out how to make the code work. We have an awesome team, especially my
brothers from other mothers – Nick Harris, Shannon Lowder, and Reeves Smith.
Donald Farmer inspires me every time we interact. As Principal Program Manager at
Microsoft, Donald worked extensively with SSIS and helped shape the product. Donald
continues to shape data software by providing vendors unique strategic guidance at
TreeHive Strategy (treehivestrategy.com).
I am certain there are many excellent editors in this business. Jonathan Gennick is
the best with whom I have had the privilege to work. Without Jill Balzano’s input and
project management, I would have been lost!
Finally, I thank my family for their understanding. My children Stevie Ray, Emma, and
Riley who live at home at the time of this writing, and Manda and Penny who have children
of their own. And Christy, to whom I dedicate this book, my wife, my love. Thank you.
—Andy

Writing this book never really entered my mind until my great friend and EDNA
colleague, Andy Leonard, convinced me to do it. I truly appreciate his confidence in me,
and it was a very interesting experience. I’m really glad that I could work together with
him on this project.
Many thanks to Jonathan Gennick, Jill Balzano, and André van Meulebrouck for all of
their help and suggestions. They made things so much easier.
Most important of all, I want to thank my wife, Ann. Much of where I am today is due
to her love, support, and encouragement. I couldn’t begin to do it without her. Thank you.

—Kent

xv
Introduction
Frameworks have existed for as long as people have been building things. When
people began developing solutions using computers, frameworks soon followed. Like
woodworking jigs, frameworks exist to simplify work and speed up the process of
developing a solution, whether the problem is to complete a woodworking project or
deliver an enterprise data integration solution.

Who Is This Book For?


Anyone who is interested in data-related automation or executing multiple chunks
of code with a single command will find value in these pages. Three audiences will
particularly benefit from this book:

1. Database developers

2. Data engineers and data integration developers

3. Business Intelligence Markup Language (Biml) developers

Database developers will learn about driving database object execution from stored
procedures and will see one example of a database framework.
Data engineers and data integration developers will learn how to use SQL Server
Integration Services (SSIS) to implement a metadata-driven data integration framework.
Biml developers will see one example of using BimlExpress and metadata to
rapidly produce several SSIS packages in selected design patterns and an example of
interrogating flat files to generate flat file formats and flat file connection managers via
Biml.

How This Book Is Structured


In the following sections, we will explore the chapter layout of this book. There are two
parts that guide you through the process of building a database framework using stored
procedures and an SSIS framework. Each of those parts is composed of several chapters.

xvii
Introduction

Part I: Stored Procedure–Based Database Frameworks


In the first part of this book, we will focus on building a database framework using
stored procedures. These chapters are targeted primarily at those who develop database
solutions. We do not endeavor to create the most comprehensive primer for every aspect
of database development; we cover the basics well.

C
 hapter 1: Stored Procedures 101
Before we dive into database development, let’s cover some basics of stored procedures.

C
 hapter 2: Automation with Stored Procedures
Once you have a solid grasp on stored procedures, we will use what we’ve learned about
stored procedures to automate execution using the controller pattern, which executes
one or more stored procedures.

C
 hapter 3: Stored Procedure Orchestrators
In this chapter, we examine high-level execution management using the orchestrator
pattern, which executes one or more controller stored procedures.

C
 hapter 4: A Stored Procedure–Based Metadata-Driven
Framework
Metadata-driven frameworks are a recurring theme in this book. In this chapter, we
store information about stored procedures, controllers, and orchestrators to execute
framework applications.

Part II: SSIS Frameworks


If your enterprise is executing a few SSIS packages, there is no need for an SSIS
framework. However, if your enterprise is executing several hundred (or several
thousand) SSIS packages, you definitely need an SSIS framework.

xviii
Introduction

C
 hapter 5: A Simple, Custom, File-Based SSIS Framework
In this chapter, we define a data integration/engineering framework metadata database
that manages configuration and execution. We introduce a version of an SSIS framework
that manages these subject areas for SSIS executed on-premises.

C
 hapter 6: Framework Execution Engine
In this chapter, we add instrumentation in the form of Information and Error events.
Built-in SSIS logging will surface these messages, which are useful when troubleshooting
SSIS framework application issues.

C
 hapter 7: Framework Logging
In this chapter, we persist execution metadata to “Instance” tables. The
ApplicationInstance table stores one record for each instance of an SSIS framework
application execution. The ApplicationPackageInstance table stores one record for each
instance of an SSIS framework application package execution. Important execution
instance attributes – such as start and end times and execution status – are maintained
in the “Instance” tables.

C
 hapter 8: Azure-SSIS Integration Runtime
In this chapter, we introduce Azure Data Factory (ADF) and the Azure-SSIS integration
runtime by walking through the provisioning processes.

C
 hapter 9: Deploy a Simple, Custom, File-Based Azure-SSIS
Framework
In Chapters 5–7, we designed and constructed an SSIS framework aimed at on-premises
SSIS execution, configuration, and logging. In this chapter, we begin migrating the SSIS
framework designed in Chapters 5–7 by provisioning a new Azure SQL database and
then deploying the metadata database to our new Azure SQL database. We provision an
Azure File Share and migrate test SSIS packages to the Azure File Share. Finally, we begin
building the Azure Data Factory parent pipeline that serves as the execution engine for
the ADF version of the SSIS framework.

xix
Introduction

C
 hapter 10: Framework Logging in ADF
In this chapter, we add logging functionality to the parent ADF pipeline, much like the
functionality we added to the on-premises version of the SSIS framework in Chapter 7.

C
 hapter 11: Fault Tolerance in the ADF Framework
In this chapter, we complete ADF execution engine functionality by implementing fault
tolerance to programmatically stop (or not stop) pipeline execution based on SSISConfig
metadata configurations.

C
 onclusion
This book is for people who want to dive deeper into SQL Server and SSIS automation.
We will be discussing and demonstrating database and Integration Services frameworks
and covering such topics as SQL Server, SSIS, Azure, and Azure Data Factory.
As you can see, we have a long journey filled with learning and new insight ahead of
us. Let’s get started!

xx
PART I

Stored Procedure-Based
Database Frameworks
CHAPTER 1

Stored Procedures 101


One of the most common issues continually facing IT organizations is finding the proper
balance between the effort to develop and deploy processes into production against the
efficiency and effectiveness of production control operators. The effort to develop and
deploy and the effectiveness of production control seem to be diametrically opposed.
Making it easier to develop and deploy processes usually means more work and manual
intervention for production control. The real question that needs to be considered is
where is it better to “feel the pain”? Pushing the effort toward the development side of
the equation can slow down the throughput but minimizes the liability of issues at the
production process level. This and the next few chapters are going to concentrate on
processes that are executed using stored procedures. In this chapter, you’ll get a basic
introduction to stored procedures that is the foundation for the chapters that follow.
You’ll see how to create a child stored procedure, and we’ll provide you a template that
you can use to create similar procedures in your own work.

The Need for a Framework


When just in development mode, it is awfully easy (and impressive) to construct
large, monolithic procedures that do everything from beginning to end. They are the
proverbial “black box” where something goes in, many gyrations take place, and then the
desired result occurs. Those are great until a problem occurs, or just a change in business
requirements means that modifications need to be made. When the procedure does
so much, what does it take to test it once the modifications are done? Even though the
change only impacts 10 percent of the procedure, the entire procedure has to be tested.
What does it take to accomplish that? What if there are several intricate modifications
that need to be made? How difficult does it become for more than one developer to work
on the changes and coordinate their efforts?

3
© Andy Leonard, Kent Bradshaw 2020
A. Leonard and K. Bradshaw, SQL Server Data Automation Through Frameworks,
https://doi.org/10.1007/978-1-4842-6213-9_1
Chapter 1 Stored Procedures 101

Now, consider that monolith broken up into multiple procedures, each of which
performs a unit of work. When a change is made and needs to be tested, that effort can
be isolated to just what is necessary to perform that unit of work, and the validation is
concentrated on the result of the procedure. And, with it now being multiple procedures,
modifications can usually be done simultaneously by multiple developers, and their
efforts can be mutually exclusive. Over time, that approach can prove to be much more
cost effective and efficient.
That is where a framework helps to organize and manage processes to provide
the most flexibility in development and can minimize the maintenance effort (which,
sometimes, is not considered until it becomes an obvious issue). A framework provides
a consistent methodology for assembling and executing processes. It also promotes
writing code in small units of work that can potentially be mixed, matched, and reused.
It adds complexity to the development and deployment processes but can reduce the
effort for production scheduling. The framework can also provide greater flexibility for
managing the execution of the process.

D
 emonstration of a Framework
To begin the analysis of the framework concept, we need a process. Our example to
follow shows a framework built to run a daily process against an example schema. The
details of that process don’t matter to the example. Just consider that any production
system might have something that needs to be done each day, and what follows is a
framework by which to make those daily processes happen.
Also, part of the example is a monthly process. Just as a system might need certain
tasks to be done each day, it’s also common to have certain things that need to be done
once monthly. In designing such a system, one must take into account the order in
which daily and monthly processes execute when their schedules intersect on – in our
example – the first of each month.
For the purpose of this book, a simple process has been developed (NOTE: all of the
code described can be downloaded at entdna.com. You can also find a link to the code
from the book’s catalog page on Apress.com). Downloading the example code enables
you to follow along with the upcoming examples on your own machine.

4
Chapter 1 Stored Procedures 101

An Example Schema


Listing 1-1 shows code to create a schema called FWDemo that will contain everything
needed for the demonstration. Also, there is code to create a table called FWDemo.
ProcessLog. Including a pattern for writing to this table throughout all of the procedures
certainly adds some complexity and overhead to the procedures, but what it provides in
monitoring and troubleshooting more than makes up for the upfront effort.

Listing 1-1. Schema and log table creation

print 'FWDemo Schema'


If Not Exists(Select name
              From sys.schemas
              Where name='FWDemo')
begin
  print ' - Creating FWDemo schema'
  declare @sql varchar(255) = 'Create Schema FWDemo'
  exec(@sql)
  print ' - FWDemo schema created'
end
Else
print ' - FWDemo schema already exists.'
print ''
GO

IF  EXISTS (SELECT * FROM sys.objects


            WHERE object_id = OBJECT_ID(N'FWDemo.ProcessLog')
              AND type in (N'U'))
    DROP TABLE FWDemo.ProcessLog
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO
5
Chapter 1 Stored Procedures 101

CREATE TABLE [FWDemo].[ProcessLog](


      [ProcessLogID]      [int] IDENTITY(1,1) NOT NULL,
      [ProcessLogMessage] [nvarchar](255)     NOT NULL,
      [CreateDate]        [smalldatetime]     NOT NULL
)
GO

SET ANSI_PADDING OFF


GO

Do you have a SQL Server instance that you can use for learning purposes? Connect
to that instance as an administrator, for example, as the sa user. Then, in SQL Server
Management Studio (SSMS), open a “New Query” window, copy the code from Listing 1-1,
and execute it to create the example schema used in this and subsequent chapters.

The Daily Process


Listing 1-2 shows the code to create two stored procedures that will make up our
demonstration Daily Process. We are providing two procedures in our example because
it’s common to have more than one, and having two allows us to show how to make the
execution of subsequent procedures depend upon the success of earlier ones – because
the need to execute a series of procedures and halt or take other actions when an error
occurs is the real-life scenario that most of us face.
These procedures (as well as all others that we will be using) can be compiled and
executed for your own testing. You will notice that there is some code commented out
(lines that are preceded with ‘--’) in each procedure that can be invoked (remove the
‘--’, then recompile) to create an error condition. This ability to create an error condition
allows testing for successful and unsuccessful completions that will become more
important as we progress through demonstration iterations in later chapters.
For the sake of this exercise, we will declare a business rule for the Daily Process
stating that FWDemo.DailyProcess1 must complete successfully before FWDemo.
DailyProcess2 can be executed. FWDemo.DailyProcess2 must then complete
successfully before the Daily Process can be deemed successfully executed.

6
Chapter 1 Stored Procedures 101

Listing 1-2. Daily Process stored procedures

If Exists(Select s.name + '.' + p.name


          From sys.procedures p
          Join sys.schemas s
            On s.schema_id = p.schema_id
          Where s.name = 'FWDemo'
            And p.name = 'DailyProcess1')
begin
  print ' - Dropping FWDemo.DailyProcess1 stored procedure'
  Drop Procedure FWDemo.DailyProcess1
  print ' - FWDemo.DailyProcess1 stored procedure dropped'
end
GO

CREATE PROCEDURE FWDemo.DailyProcess1


AS
---------------------------------------------------------------------------
---------------------------------------------------------------------------
--
-- Purpose: This procedure is part of the Stored Procedure Framework Demo.
--
-- NOTE: An Error situation can be created for testing/demo purposes by
--    un-commenting the Error code in the body of the procedure.  To return
--    to a procedure with a successful execution, re-comment the code or    
--    recompile the original.
--
---------------------------------------------------------------------------
---------------------------------------------------------------------------

SET NOCOUNT ON

/*********************************************/
/*  Log the START of the procedure to the process log  */
/*********************************************/

7
Chapter 1 Stored Procedures 101

INSERT INTO FWDemo.ProcessLog (


      ProcessLogMessage,
      CreateDate
)
Values ('Procedure FWDemo.DailyProcess1 - STARTING',
      GETDATE()
)

DECLARE @RetStat int

SET @RetStat = 0

/******************************************/
/*  Force an ERROR CONDITION for this procedure  */
/******************************************/

--INSERT INTO FWDemo.ProcessLog (


--    ProcessLogMessage,
--    CreateDate
--)
--VALUES ('Procedure FWDemo.DailyProcess1 - Problem Encountered',
--    GETDATE()
--)
--SET @RetStat = 1

/****************************************************/
/*  Log the COMPLETION of the procedure to the process log     */
/****************************************************/

IF @RetStat = 0
   BEGIN
      INSERT INTO FWDemo.ProcessLog (
            ProcessLogMessage,
            CreateDate
      )
      VALUES ('Procedure FWDemo.DailyProcess1 - COMPLETED',
            GETDATE()
      )

8
Chapter 1 Stored Procedures 101

   END
ELSE
   BEGIN
      INSERT INTO FWDemo.ProcessLog (
            ProcessLogMessage,
            CreateDate
      )
      VALUES ('Procedure FWDemo.DailyProcess1 - ERROR',
      GETDATE()
      )
   END

RETURN @RetStat
GO

If Exists(Select s.name + '.' + p.name


          From sys.procedures p
          Join sys.schemas s
            On s.schema_id = p.schema_id
          Where s.name = 'FWDemo'
            And p.name = 'DailyProcess2')
begin
  print ' - Dropping FWDemo.DailyProcess2 stored procedure'
  Drop Procedure FWDemo.DailyProcess2
  print ' - FWDemo.DailyProcess2 stored procedure dropped'
end
GO

CREATE PROCEDURE FWDemo.DailyProcess2


AS
---------------------------------------------------------------------------
---------------------------------------------------------------------------
--
-- Purpose: This procedure is part of the Stored Procedure Framework Demo.
--

9
Chapter 1 Stored Procedures 101

-- NOTE: An Error situation can be created for testing/demo purposes by


--    un-commenting the Error code in the body of the procedure.  To return
--    to a procedure with a successful execution, re-comment the code or
--    recompile the original.
--
---------------------------------------------------------------------------
---------------------------------------------------------------------------

SET NOCOUNT ON

/*********************************************/
/*  Log the START of the procedure to the process log  */
/*********************************************/

INSERT INTO FWDemo.ProcessLog (


      ProcessLogMessage,
      CreateDate
)
Values ('Procedure FWDemo.DailyProcess2 - STARTING',
      GETDATE()
)

DECLARE @RetStat int

SET @RetStat = 0

/******************************************/
/*  Force an ERROR CONDITION for this procedure  */
/******************************************/

--INSERT INTO FWDemo.ProcessLog (


--    ProcessLogMessage,
--    CreateDate
--)
--VALUES ('Procedure FWDemo.DailyProcess2 - Problem Encountered',
--    GETDATE()
--)

10
Chapter 1 Stored Procedures 101

--SET @RetStat = 1

/****************************************************/
/*  Log the COMPLETION of the procedure to the process log     */
/****************************************************/

IF @RetStat = 0
   BEGIN
      INSERT INTO FWDemo.ProcessLog (
            ProcessLogMessage,
            CreateDate
      )
      VALUES ('Procedure FWDemo.DailyProcess2 - COMPLETED',
            GETDATE()
      )
   END
ELSE
   BEGIN
      INSERT INTO FWDemo.ProcessLog (
            ProcessLogMessage,
            CreateDate
      )
      VALUES ('Procedure FWDemo.DailyProcess2 - ERROR',
            GETDATE()
      )
   END

RETURN @RetStat
GO

In a “New Query” window in SSMS, execute the code from Listing 1-2 while
connected to the FWDemo schema. The code creates two stored procedures that
together make up a daily process. With those procedures in place, you can turn your
attention to the next problem, which is to schedule those procedures to actually run each
day.

11
Chapter 1 Stored Procedures 101

Executing the Daily Process


Now that an environment has been built and a process created, let’s turn to the
execution. Operations staff will have to set up or schedule the procedures to run and
either monitor for any error conditions that are raised or set up precedence rules if such
a function exists in any scheduling tool used. In a basic sense, we now have a Daily
Process that is ready for production. Listing 1-3 shows the statements that can be used
to execute the Daily Process procedures and also a SELECT statement that can be run
to view the output written to FWDemo.ProcessLog. You will notice that we are ordering
the output in a descending order. This will show the most recent messages at the top and
eliminate the need to scroll down to get to the messages for the current execution and
much easier once the log starts to become heavily populated.

Listing 1-3. Daily Process execute statements and process log SELECT statement

EXECUTE FWDemo.DailyProcess1

EXECUTE FWDemo.DailyProcess2

SELECT ProcessLogID
      ,ProcessLogMessage
      ,CreateDate
FROM FWDemo.ProcessLog
ORDER BY ProcessLogID desc

Including a Monthly Process


Now it’s time to add another layer to our production process. In Listing 1-4, there is
code to create two more stored procedures that will make up a Monthly Process. The
procedures operate the same as our daily process procedures, and there are some
business rules associated with them. First, the monthly process will run on the first day
of the month. Second, it will run after the successful execution of the Daily Process,
and third, FWDemo.MonthlyProcess1 must complete successfully before FWDemo.
MonthlyProcess2 can be executed.

12
Chapter 1 Stored Procedures 101

Listing 1-4. Monthly Process stored procedures

If Exists(Select s.name + '.' + p.name


          From sys.procedures p
          Join sys.schemas s
            On s.schema_id = p.schema_id
          Where s.name = 'FWDemo'
            And p.name = 'MonthlyProcess1')
begin
  print ' - Dropping FWDemo.MonthlyProcess1 stored procedure'
  Drop Procedure FWDemo.MonthlyProcess1
  print ' - FWDemo.MonthlyProcess1 stored procedure dropped'
end
GO

CREATE PROCEDURE FWDemo.MonthlyProcess1


AS
---------------------------------------------------------------------------
---------------------------------------------------------------------------
--
-- Purpose: This procedure is part of the Stored Procedure Framework Demo.
--
-- NOTE: An Error situation can be created for testing/demo purposes by
--    un-commenting the Error code in the body of the procedure.  To return
--    to a procedure with a successful execution, re-comment the code or
--    recompile the original.
--
---------------------------------------------------------------------------
---------------------------------------------------------------------------

SET NOCOUNT ON

/*********************************************/
/*  Log the START of the procedure to the process log  */
/******************************** ************/

13
Chapter 1 Stored Procedures 101

INSERT INTO FWDemo.ProcessLog (


      ProcessLogMessage,
      CreateDate
)
Values ('Procedure FWDemo.MonthlyProcess1 - STARTING',
      GETDATE()
)

DECLARE @RetStat int


SET @RetStat = 0

/******************************************/
/*  Force an ERROR CONDITION for this procedure  */
/******************************************/

--INSERT INTO FWDemo.ProcessLog (


--    ProcessLogMessage,
--    CreateDate
--)
--VALUES ('Procedure FWDemo.MonthlyProcess1 - Problem Encountered',
--    GETDATE()
--)
--SET @RetStat = 1

/****************************************************/
/*  Log the COMPLETION of the procedure to the process log     */
/****************************************************/

IF @RetStat = 0
   BEGIN
      INSERT INTO FWDemo.ProcessLog (
            ProcessLogMessage,
            CreateDate
      )
      VALUES ('Procedure FWDemo.MonthlyProcess1 - COMPLETED',
            GETDATE()
      )
   END

14
Random documents with unrelated
content Scribd suggests to you:
63. “Marcus Antonius,” p. 119. Skeat.

64. “Marcus Antonius,” p. 164. Skeat.

65. Pescetti throughout this scene follows Appian rather than


Plutarch. Appian says: “Some thought that Antony ought to be
killed also because he was consul with Caesar, and was his
most powerful friend, and the one of the most repute with the
army; but Brutus said that they would win the glory of
tyrannicide from the death of Caesar alone, because that
would be the killing of a king. If they should kill his friends
also, the deed would be imputed to private enmity and to the
Pompeian faction.” (Civil Wars, Bk. II, Ch. XVI., White’s Trans.)

66. This parallel is noted by Ayres (in work cited before).

67. Noted by Ayres.

68. Substantially the same in Appian.

69. Marcus Brutus, p. 117–118.

70. J. C., Act. III., Sc. I, ll. 14–27.

71. P. 91 ff.

72. In the monograph to which reference has already been made.

73. Page 24. See later chapter on Brutus.

74. Compare Antony’s outburst:


Thou art the ruins of the noblest man
That ever lived in the tide of times. J. C. III., 1, 257–
58.
75. This is a detail which Pescetti derived from Appian’s “Civil
Wars,” Bk. II., Ch. XVI., wherein it is stated that the
conspirators had to hasten, as Caesar contemplated departing
for Parthia within four days and would thereupon have a
bodyguard. (White’s translation, p. 176.)

76. Pp. 76–77. This speech, in substance, occurs both in Muretus


and in Grévin.

77. I., ii. 199.

78. Pp. 93, 94, 95. There are some similarities to “Cornelie” and to
Grévin in this passage.

79.
“Have I in conquest stretch’d mine arm so far,
To be afeard to tell graybeards the truth?”

80. He taught grammar and rhetoric in Verona. See Gerini, “Gli


scrittori pedagogici nel secolo decimo settimo.”

81. Paolo Beni was quick to seize upon this feature of Pescetti’s
characterization of Caesar. He says: “Che se pur volesse alcuno
che non perciò restasse suo Cesare di esser furto, almen
convien confessare ch’egli solo fosse vero Autore dell’ingiuria la
quale con tanta sciocchezza e temerità fece in tal Tragedia a
quell’Altezza et a tutta la serenissima Casa d’Este, poscia che
havendo pubblicato e celebrato Alfonso per congiuntissimo di
sangue con la Casa Giulia, e con Giulio Cesare, finalmente si
adduce a dedicarli la sua Tragedia; (che sua chiamerolla per
hora) quella Tragedia dico nella qual Cesare vien com’empio
tiranno e traditor della patria bruttamente trucidato. Vedi
imprudenza estrema di quest’huomo: vedi sciocchezza et
audacia incomparabile: ricordare che questo serenissimo
Principe sia per sangue strettamente congiunto con Giulio
Cesare, e disceso da Giulio Cesare, e poi immantinente far che
il Theatro per ogni parte risuoni l’impietà, la perfidia, la tirannia
di Cesare: e che su gli occhi di quell’Altezza ne venga quasi
pernitioso mostro co’l ferro trucidato et estinto. E forse che
non supplica il Serenissimo Alfonso (vedi nuova imprudenza et
ardire) che faccia rappresentar questa Tragedia in publico con
nobil pompa, e dia spettacolo sì horrendo d’un suo antenato al
Mondo.” Il Cavalcanti, 1614, p. 107 et seq.

82. It is interesting to note the fascination which this remark of


Caesar’s had for the dramatists of his fortunes. No doubt they
drew their direct inspiration from Plutarch, who relates that
Caesar, on being urged to have a bodyguard, retorted, “It is
better to die once, than always to be afraid of death.” (J. C., p.
92.) Skeat.
Thus Muretus says (Act III., verse 386):
“Sed tamen quando semel
Vel cadere praestat, quam metu longo premi.”

And Grévin, Act III., v. 791:


“. . . . . . . et si j’aime bien mieux
Mourir tout en un coup, qu’estre tousjours paoureux.”

Also Act I., v. 13:


“Il vault bien mieux mourir
Asseure de tout poinct, qu’incessamment perir.
Faulsement par la peur.”

In Garnier’s “Cornelie” (Kyd’s trans.) we read:


“The fear of evil doth afflict us more
Than the evil itself, though it be neer so sore.”
83. Pp. 39–40. Also pages 79, 80, 82, 83 and 94, in which this
same idea finds expression.

84. This is not the case in Muretus or Grévin, nor is it found in


Plutarch.

85. True, the conspirators have suspected that the portents and
the auspices might persuade him, and Trebonius has prepared
for this. But how was Caesar to know?

86. I., ii, 182.

87. MacCallum, op. cit., p. 228.

88. “Shakespeare, A Critical Study of his Mind and Art,” by Edward


Dowden, Harper & Bros., 1903, pp. 253–54.

89. E per non fare ora qui (che nè il luogo, nè l’occasione il ricerca)
un catalogo di tutti, chi dell’ antico, ò del moderno secolo
possiam noi trovare, che a Cesare somigli più, e faccia meglio
parallelo di quel, che fa la Sereniss. Altezza Vostra? Sol che
quelli fosse stato Cristiano, e avesse saputo contentarsi d’esser
il primo della sua Città, senza voler esser anche della stessa
Città più potente, ò Signor legittimo fosse suto; . . . “Cesare,”
Dedication, p. 2.

90. In the classic drama it is not unusual for the Chorus to speak in
the first person, but this instance is unique in Pescetti. It
strikes the reader with all the force of an individual opinion of
the author.

91. In the Prologue, Jove comforts Venus, saying:


“Giulio, della cui morte tanto lutto
Meni, e cordoglio, e sì ti lagni, e duoli,
Risplenderà doman in ciel al pari
Della tua stella; . . .” Prologue, p. 10.
92. As is well known, Plutarch nowhere condemns Brutus for his
murder of Caesar. Appian, however, while he recognizes Brutus’
virtues, is strong in condemnation of his act. He says: “Against
all these virtues and merits must be set down the crime
against Caesar, which was not an ordinary or a small one, for it
was committed unexpectedly against a friend, ungratefully
against a benefactor who has spared them in war, and
nefariously against the head of the state, in the senate house,
against a pontiff clothed in his sacred vestments, against a
ruler without an equal, who was most useful above all other
men to Rome and its empire.” Civil Wars, White’s Trans., p.
381.
It is curious to note how Pescetti here abandons Appian in
favor of Plutarch.

93. Just before the discussion concerning Antony, already quoted.

94. From these words the reader may believe that the conspirators
feared that very courage of which Caesar himself proves
deficient. But by courage, Cassius here means sheer physical
bravery, an attribute which no reader either of Pescetti or of
Shakespeare can deny him. The courage Caesar lacked was
that of his own convictions. Like Macbeth, the known had no
terrors for him, but like the Scottish king, he is confounded by
the unseen. No Roman could have found fault with a man for
heeding the warning of the gods. The historical Caesar, it is
true, oft expressed his contempt for omens, while the Caesar
of the drama professes to disregard them. But his disregard is
superficial, and apparently the result of an attitude which we
cannot but attribute to a belief in his own semi-divine being.
Rather than be suspected of feelings common enough to
ordinary mortals, Caesar deludes himself by a process of self-
hypnotism, and is led to his doom, a victim of his lack of true
courage, a sacrifice to his own inordinate vanity.
95. P. 24. Is this perhaps the hint from which Shakespeare built up
the entire scheme of physical comparisons dwelt upon by
Cassius? The swimming of the Tiber, for instance?

96. I., ii, 95.

97. I., ii, 308.

98. I., ii, 33–34.

99. I., ii, 89–90.

100.
I., ii, 54–61.

101.
I., iii, 157.

102.
II., i, 90.

103.
II., i, 321.

104.
II., i, 332.

105.
Probably because it involved a profanation of the sacred
precincts of the Senate. But one might expect such an ardent
patriot to regard Caesar’s death here as a very acceptable
sacrifice to the gods he supposedly outraged. But see Appian.

106.
II., i, 77.

107. II., i, 61.


108.
II., i, 124.

109.
P. 109.

110.
III., i, 22.

111.
V., i, 109.

112.
P. 216–217, MacCallum.

113.
The conclusion is irresistible that Pescetti was very much under
the influence of Lucan. This is true not alone of the
supernatural element, but also of the general attitude of Brutus
and Cassius, who talk of Caesar very much in the spirit of the
Pharsalia. In Book IX. Lucan describes how the soul of Pompey
leaving the tomb soars to the abodes of the Blessed and
thence looking down upon the earth inspires the breasts of
Brutus and Cato. (Lines 1–23.)

114.
P. 17.

115.
Pp. 89–90.

116.
In Muretus the case against Caesar is also weak. In Grévin,
Brutus in his speech to the citizens makes definite charges:
“Ce Tyran, ce Cesar, enemi du Senat,
Oppresseur du pays, qui de son Consulat
Avoit faict heritage, e de la Republique
Une commune vente en sa seule practique,
Ce bourreau d’innocens, ruine de nos loix,
La terreur des Romains, e le poison des droicts,
Ambitieux d’honneur, qui monstrant son envie,
S’estoit faict appeler Pere de la patrie,
E Consul à jamais, à jamais Dictateur,
Et pour comble de tout, du surnom d’Empereur.
Il est mort ce meschant, qui decelant sa rage,
Se feit impudemment eslever un image
Entre les Rois, aussi il a eu le loyer
Par une mesme main qu’eut Tarquin le dernier.”

(Lines 1017 ff.)

117. There is no doubt that Pescetti found in Muretus the hints for
some of Brutus’ speeches, but his loans from his predecessor
do not affect the argument.

118.
But, as usual, Pescetti fails to take full advantage of this motif.
During the wordy progress of the drama we lose sight of
Antony, and only a few lines at the end suggest him as the
Nemesis of the conspirators.

119.
See section on Portia.

120.
In regard to Antony and the Popilius Lena episode.

121.
In Muretus she has no place in the action. Brutus refers to her
in his soliloquy: Act II., lines 107 ff.
Brutus— “. . . Haec parum si te movent,
Tua jam, vir ut sis, te satis conjux monet,
Fidem cruore quae tibi obstrinxit suam,
Testata sic se avunculi prolem tui.
Si ab exequendis te avocat coeptis timor,
Animusque pigro torpet ignavus gelu,
Ex femina perdisce, quid deceat virum.”
This is the only reference to Portia throughout the drama.
Grévin makes no mention of her, while Garnier, in his “Porcie”
(1568) treats of events following the death of Caesar.

122.
I know of but two notices of these scenes, neither being much
more than a mere mention. Neri says: “Su tutte ancora
primeggia il Cesare d’Orlando Pescetti, che per il rilievo della
figura di Bruto, tratta da Plutarco—vedi la bella scena di Porzia
nel secondo atto, etc.” (La Tragedia italiana nel Cinquecento,
Ferdinando Neri, Firenze, 1904, p. 158.) It is also referred to
by Emilio Bertana in “La tragedia,” Milano, 1904, p. 75 ff.

123.
Plutarch notes that she was of a “noble courage.”

124.
That is, Fortune.

125.
Marcus Brutus, p. 116. Skeat.
In the “Julius Caesar” of Sir William Alexander, (Earl of Stirling)
written a few years after Shakespeare’s play, there is a decided
similarity between some portions of the Brutus-Portia scenes
and those in Pescetti. The prologue seems an echo of
Pescetti’s. Nor do these portions have anything verbally in
common with Seneca, the model of both tragedies. See
Conclusion, page 121.
126.
Many of the motifs of the Calpurnia-Nurse scene in Pescetti are
derived from Muretus. Others are reminiscent of Grévin.

127. Malone long ago suggested that this scene probably refers to
the popularity of the play on the stage, and that it points to
other contemporary dramas on the same subject.
Prolegomena, II, ff. 448–9. Ed. 1823. Prof. Sykes sees in it a
dramatic device to emphasize the reality of the presentation.
“Julius Caesar” note, page 142.

128.
“Connections between the Drama of France and Great Britain,
particularly in the Elizabethan Period.” Harvard Dissertation,
1900 (unpublished), quoted by Ayres.

129.
Alexander’s Prologue is the first act of the drama. Juno delivers
a long monologue and the chorus closes the act. In Muretus,
Caesar and the chorus occupy the first act. In Grévin, it is
Caesar, Antony and the Chorus of Soldiers. In Pescetti, the
Prologue is separate, but like in Alexander the actors therein
do not appear in the drama proper.

130.
Of the above only the fact that the conspiracy was revealed to
her is recorded by Plutarch in this connection.

131.
Fortune.

132.
Alexander, in his younger days, travelled in France, Spain and
Italy. He was high in the favor of James VI. of Scotland and
accompanied him to London in 1603, where he became an
intimate of Prince Henry. That he was well and favorably
known to the authors of the day may be inferred from the
dedication of a sonnet to him by Michael Drayton.

133.
In Shakespeare Soc. Pub., 1874, p. 357. Also his Life of
Shakespeare, 1886, p. 215–6.

134.
The allusion to the phrase Act III, Sc. 1.
“Know, Caesar doth not wrong, nor without cause
Will he be satisfied.”

This originally stood:


“Caesar did never wrong but with just cause” and is ridiculed
by Jonson in his “Discoveries.” It is quite likely that the Caesar
in the play as originally written was an even more self-
important individual than he is at present. Possibly
Shakespeare saw no absurdity in the line when he first penned
it. Caesar, in his own estimation, is semi-divine. The cause of
things is in his will. What might seem wrong to the mob was
not so to Caesar, for he felt that the cause was just, no matter
what the world thought. That was sufficient. The apparent
contradiction in terms thus seems capable of explanation.

135.
Appendix to Vol. IV of the Cambridge History of English
Literature. Also M. A. Scott, Elizabethan Translations from the
Italian. Mod. Lang. Assoc. Pub., X. to XIV., 1895–99.

136.
Sidney Lee, The French Renaissance in England, 1910. Phoebe
Sheavyn, The Literary Profession in the Elizabethan Age, 1909.

137. Shakespeare: A Critical Study, George Brandes—London,


William Heineman, 1902, p. 444–45.
138.
“Relazioni Litterarie fra Italia e Inghilterra,” Florence, 1911.
Reviewed in article, “The Italian Sources of Othello,” by Ethel
M. de Fonblanque, Fortnightly Review, Nov., 1911, p. 907.

139.
Ethel M. de Fonblanque in Fortnightly Review, Nov., 1911.

140.
“Studies in Shakespeare.”

141.
In his discussion of the state of the Italian drama during the
sixteenth century, Symonds says: “At the same time, we may
question whether the Despots would have welcomed tragic
shows which dramatized their deeds of violence; whether they
would have suffered the patriotism of a Brutus, the vengeance
of Virginius, the plots of Catiline, or the downfall of Sejanus to
be displayed with spirit-stirring pomp in the theatres of Milan
and Ferrara, when conspiracies like that of Olgaiti were
frequent.” John Addington Symonds, “The Renaissance in Italy,
Italian Literature,” Vol. II., p. 119. Henry Holt & Co., 1888.

142.
“The Monarchicke Tragedies” of Alexander by 1617 had gone
through three editions, besides several single quartos.
TRANSCRIBER’S NOTES
1. Retained the blanks that the original Italian text
often had before apostrophes.
2. Inserted a blank before the apostrophe in front
of the letter l, whenever the apostrophed ’l
stands for il.
3. Changed “προσέττατεν” to “προσέταττεν” in
footnote 12.
4. Added anchor after “—II., i, ll. 154–191.” for the
first footnote[60] on p. 46.
5. Changed “cosi” to “così” on p. 67.
6. Changed “angurio” to “augurio” on p. 84.
7. Silently corrected typographical errors.
8. Retained anachronistic and non-standard
spellings as printed.
The following corrections to
obvious Italian misspellings in
Boecker's text made by
comparing excerpts with
Pescetti's original (this copy).
1. Changed “Secundo” to “secondo” on p. 1.
2. Changed “ricchezze” to “ricchezze” on p. 16.
3. Changed “Più che d’Orso, e de Tigre Ircana
crudo” to “Più che d’Orso, e di Tigre Ircana
crudo” on p. 17.
4. Changed “E fù si grande del ferir la voglia
Ricandosi” to “E fu sì grande del ferir la voglia
Recandosi” on p. 24.
5. Changed “Immenso regno, e sì gonfiato ha
l’onde,” to “Immenso regno, e sì gonfiato hà
l’onde,” on p. 30.
6. Changed “Altri temer gran fatto, un’huom al
ventre” to “Altri temer gran fatto, un’huomo al
ventre” on p. 43.
7. Changed “Sciogliam noi l’alma de’ corporei lacci.”
to “Sciogliam noi l’alma da corporei lacci.” on
p. 53.
8. Changed “Ben t’esort’ io guardati de’ nemici.” to
“Ben t’esort’ io guardarti de’ nemici.” on p. 61.
9. Changed “Quest’ alta impresa il cielo, acciochè
nulla” to “Quest’ alta impresa il cielo,
acciocchè nulla” on p. 63.
10. Changed “Non può salir, che del terreno incarco”
to “Non può salir, chi del terreno incarco” on
p. 66.
11. Changed “Et ei conforme al merto suo nel
propio” to “Et ei conforme al merto suo nel
proprio” on p. 92.
12. Changed “Non senza gran cagion stamane
uscito” to “Non senza gran cagion stamane
uscito” on p. 101.
13. Changed “Ite, ò forti, ite ò saggi, te ò de gli alti”
to “Ite, ò forti, ite ò saggi, ite ò de gli alti” on
p. 107.
14. Changed “te ò de gli alti Lenaggi,” to “ite ò de gli
alti Legnaggi,” on p. 114.
*** END OF THE PROJECT GUTENBERG EBOOK A PROBABLE
ITALIAN SOURCE OF SHAKESPEARE'S "JULIUS CÆSAR" ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project Gutenberg™
works in compliance with the terms of this agreement for
keeping the Project Gutenberg™ name associated with the
work. You can easily comply with the terms of this agreement
by keeping this work in the same format with its attached full
Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and
with almost no restrictions whatsoever. You may copy it,
give it away or re-use it under the terms of the Project
Gutenberg License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country
where you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of
the copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute


this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite these
efforts, Project Gutenberg™ electronic works, and the medium
on which they may be stored, may contain “Defects,” such as,
but not limited to, incomplete, inaccurate or corrupt data,
transcription errors, a copyright or other intellectual property
infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be
read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU AGREE
THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT
LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT
EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE
THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person
or entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you
do or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like