ATTACHMENT 6 SQL Server 2012 Programming Standards



Similar documents
Oracle 10g PL/SQL Training

Developing Microsoft SQL Server Databases 20464C; 5 Days

SQL Server An Overview

SQL Server 2008 Core Skills. Gary Young 2011

Developing Microsoft SQL Server Databases MOC 20464

20464C: Developing Microsoft SQL Server Databases

Course 20464: Developing Microsoft SQL Server Databases

Demystified CONTENTS Acknowledgments xvii Introduction xix CHAPTER 1 Database Fundamentals CHAPTER 2 Exploring Relational Database Components

Developing Microsoft SQL Server Databases

Implementing a Microsoft SQL Server 2005 Database

David Dye. Extract, Transform, Load

Developing Microsoft SQL Server Databases (20464) H8N64S

SQL Databases Course. by Applied Technology Research Center. This course provides training for MySQL, Oracle, SQL Server and PostgreSQL databases.

SQL SERVER DEVELOPER Available Features and Tools New Capabilities SQL Services Product Licensing Product Editions Will teach in class room

Course 20464C: Developing Microsoft SQL Server Databases

Using SQL Server Management Studio

Writing Queries Using Microsoft SQL Server 2008 Transact-SQL

Oracle Database: SQL and PL/SQL Fundamentals

Querying Microsoft SQL Server (20461) H8N61S

How To Create A Table In Sql (Ahem)

Oracle SQL. Course Summary. Duration. Objectives

A basic create statement for a simple student table would look like the following.

Module 1: Getting Started with Databases and Transact-SQL in SQL Server 2008

Outline. MCSE: Data Platform. Course Content. Course 10776C: MCSA: Developing Microsoft SQL Server 2012 Databases 5 Days

Implementing a Data Warehouse with Microsoft SQL Server 2012

Implement a Data Warehouse with Microsoft SQL Server 20463C; 5 days

Oracle(PL/SQL) Training

Writing Queries Using Microsoft SQL Server 2008 Transact-SQL

Database Programming with PL/SQL: Learning Objectives

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification

Implementing a Data Warehouse with Microsoft SQL Server

Oracle Database: SQL and PL/SQL Fundamentals NEW

Maintaining Stored Procedures in Database Application

>>Dream, Strive and Achieve Victory>> SQL Server 2005/2008 DBA SSIS and SSRS Training Contact

Exploring Microsoft Office Access Chapter 2: Relational Databases and Multi-Table Queries

About database backups

Continuous integration for databases using Red Gate tools

AV-005: Administering and Implementing a Data Warehouse with SQL Server 2014

COURSE 20463C: IMPLEMENTING A DATA WAREHOUSE WITH MICROSOFT SQL SERVER

Instant SQL Programming

Implementing a Data Warehouse with Microsoft SQL Server

Triggers & Packages. {INSERT [OR] UPDATE [OR] DELETE}: This specifies the DML operation.

Oracle Database: SQL and PL/SQL Fundamentals

Using SAS as a Relational Database

Continuous integration for databases using

SQL Server for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach

T-SQL STANDARD ELEMENTS

Learning SQL Data Compare. SQL Data Compare - 8.0

Implementing a Data Warehouse with Microsoft SQL Server MOC 20463

COURSE OUTLINE MOC 20463: IMPLEMENTING A DATA WAREHOUSE WITH MICROSOFT SQL SERVER

The first time through running an Ad Hoc query or Stored Procedure, SQL Server will go through each of the following steps.

Implementing a SQL Data Warehouse 2016

SQL SERVER TRAINING CURRICULUM

Teradata Utilities Class Outline

Programming with SQL

SQL, PL/SQL FALL Semester 2013

Microsoft SQL Server Security & Auditing. March 23, 2011 ISACA Chapter Meeting

Querying Microsoft SQL Server 20461C; 5 days

Microsoft Dynamics GP econnect Installation and Administration Guide

Teach Yourself InterBase

How To Improve Performance In A Database

Beginning SQL Server Administration. Apress. Rob Walters Grant Fritchey

Querying Microsoft SQL Server

Design and Implementation

East Asia Network Sdn Bhd

LearnFromGuru Polish your knowledge

Oracle Database 10g: Introduction to SQL

BCA. Database Management System

MODULE FRAMEWORK : Dip: Information Technology Network Integration Specialist (ITNIS) (Articulate to Edexcel: Adv. Dip Network Information Specialist)

IT2305 Database Systems I (Compulsory)

5. CHANGING STRUCTURE AND DATA

MOC 20461C: Querying Microsoft SQL Server. Course Overview

Oracle Database 10g Express

Continuous integration for databases using Redgate tools

Introduction to Database. Systems HANS- PETTER HALVORSEN,

Improving database development. Recommendations for solving development problems using Red Gate tools

Would-be system and database administrators. PREREQUISITES: At least 6 months experience with a Windows operating system.

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

Postgres Plus xdb Replication Server with Multi-Master User s Guide

DATABASE MANAGEMENT SYSTEM PERFORMANCE ANALYSIS AND COMPARISON. Margesh Naik B.E, Veer Narmad South Gujarat University, India, 2008 PROJECT

Course 20461C: Querying Microsoft SQL Server Duration: 35 hours

Course Outline: Course: Implementing a Data Warehouse with Microsoft SQL Server 2012 Learning Method: Instructor-led Classroom Learning

50439B: Basics of Transact SQL with SQL Server 2008 R2

Course ID#: W 35 Hrs. Course Content

WHITEPAPER. Improving database development

DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added?

Implementing a Data Warehouse with Microsoft SQL Server 2012

Implementing a Data Warehouse with Microsoft SQL Server 2012 (70-463)

SQL Server Developer Training Program. Topics Covered

SQL Server. 1. What is RDBMS?

Oracle Database Development Standards For DNR Staff and Contractors. Table of Contents

Implementing a Data Warehouse with Microsoft SQL Server 2012 MOC 10777

Implementing a Data Warehouse with Microsoft SQL Server

Microsoft. Course 20463C: Implementing a Data Warehouse with Microsoft SQL Server

Access Tutorial 2 Building a Database and Defining Table Relationships

Introduction to Microsoft Jet SQL

Course 10777A: Implementing a Data Warehouse with Microsoft SQL Server 2012

Introduction This document s purpose is to define Microsoft SQL server database design standards.

Transcription:

ATTACHMENT 6 SQL Server 2012 Programming Standards SQL Server Object Design and Programming Object Design and Programming Idaho Department of Lands

Document Change/Revision Log Date Version Author Description of Change 11/15/2013 2 Scott Nicholson Final released 01/13/2014 3 Scott Nicholson Renamed, reformatted, and edited for accuracy and content 02/06/2014 4 Scott Nicholson Removed references to SSISAutomation and updated to reflect the Microsoft Deployment Model. 02/10/2014 5 Scott Nicholson Added recommendation to use SSIS as data migration method. 2

Contents 1 Purpose... 4 2 T-SQL Programming Conventions... 4 2.1 Database... 4 2.2 Tables... 4 2.2.1 Columns... 4 2.2.2 Referential Integrity... 4 2.2.3 Triggers... 4 2.2.4 Indexes... 4 2.3 Views... 4 2.4 Programmability... 4 2.4.1 General... 4 2.4.2 Data Modifications... 5 2.4.2.1 INSERT Statements...5 2.4.2.2 UPDATE and DELETE Statements...5 2.4.2.3 Error Handling...5 3 SSIS Programming... 5 3.1 Assemblies... 5 3.2 SSIS Package Design... 5 3.2.1 Configuration... 5 3.2.2 Connections... 5 3.2.3 Expressions/Variables... 6 3

1 Purpose This document identifies the Idaho Department of Lands (IDL) database development standards that facilitate ease of design, troubleshooting, and maintenance. It is considered a living document and modifications will be made when necessary. This guidance is applicable to all new development and applies when refactoring existing database objects. 2 T-SQL Programming Conventions 2.1 Database Submit Database alterations scripts to source control after technical review. 2.2 Tables Explicitly define a Primary Key as the Clustered Index where feasible. Explicitly define a surrogate key. 2.2.1 Columns Initially assign the smallest feasible Unicode Data Type. Foreign Key columns are same name as Foreign Table column. Not Null constraint set where feasible. 2.2.2 Referential Integrity Explicitly define Foreign Keys where possible. Triggers will not enforce integrity within the same database. Cascading Update and Delete option disabled. 2.2.3 Triggers Triggers are not used. 2.2.4 Indexes Define the Primary Key as the clustered index on the table. Define Index on Foreign Key columns. Specify Index Fill Factor property. Explicitly define a Clustered Index where feasible. Define Index with the most selective (unique) column(s) first. Define Unique Indexes instead of Unique Constraints. 2.3 Views Include Brief description in Extended Properties. Upper Case all T-SQL Reserved Keywords (e.g. SELECT, FROM, WHERE, JOIN, etc.). Place a comma at the beginning of each statement line. Explicitly specify each column returned by the query. Explicitly reference table objects by the fully qualified name (e.g. [Common].[dbo].[tblCounty]). Define joins within ANSI standard. Provide meaningful table alias whenever referencing multiple tables. Consider using the AS clause when aliasing tables. Minimize use of DISTINCT keyword. Minimize use of ORDER BY clause. 2.4 Programmability 2.4.1 General Include Brief description in Extended Properties. Upper Case all T-SQL Reserved Keywords (e.g. SELECT, FROM, WHERE, JOIN, etc.). Explicitly SET NOCOUNT ON option. Place a comma at the beginning of each statement line. o Example: 4

SELECT [FirstName] = au.[userfirstname],[lastname] = au.[userlastname] FROM [Database].[dbo].[AppUser] AS au Explicitly specify each column returned by the query. Explicitly reference table objects by the fully qualified name (e.g. [Common].[dbo].[tblCounty]). Declare DDL for temporary tables and table variables at the beginning of the code. Explicitly drop temporary tables when the stored procedure is complete. Define joins within ANSI standard. Provide meaningful table alias whenever referencing multiple tables. Consider using the AS clause when aliasing tables. Minimize use of DISTINCT keyword. Minimize use of ORDER BY clause. 2.4.2 Data Modifications 2.4.2.1 INSERT Statements Encapsulate single or multiple table inserts into a single transaction. Provide explicit list for INSERT INTO statements. Consider TRY CATCH blocks with ROLLBACK TRANSACTION to prevent partial data addition. 2.4.2.2 UPDATE and DELETE Statements Encapsulate single or multiple table updates into a single transaction Consider TRY CATCH blocks with ROLLBACK TRANSACTION to prevent partial data modification. Add a line break for each column updated in the statement. Consider creating temporary tables or table variables that restrict data for large UPDATE/DELETE transactions. 2.4.2.3 Error Handling DML procedures return a value of zero to indicate success. DML procedures define only one exit point for success and one exit point for failure. 3 SSIS Programming IDL strongly recommends handling all data migration tasks within SSIS package transactions to prevent unanticipated data additions or removals from the target database. SQL Server Integration Service (SSIS) is a powerful successor to the Data Transformation Service (DTS). Many capabilities have been added and will be addressed in this document. To facilitate portability, the Microsoft deployment model has been adopted, utilizing SSISDB to hold parameters associated with each package / project. 3.1 Assemblies Any binary files being used as assemblies are located in the C:\Program Files\Microsoft SQL Server\IdlBin (IDL Binaries) folder. 3.2 SSIS Package Design Good design will provide clues to needed processes within any package. Peer review is highly encouraged to assure accuracy and prevent oversight. Flow diagrams will help with the control flow of any SSIS package. Use of annotations should be frequent and explicit. 3.2.1 Configuration Portability from the development environment to the testing environment and then to the production environment must be accurate and timely. Databases, file locations, email groups, etc. should be defined in a container that can be readily modified. The primary configuration information is contained in the database SSISDB. 3.2.2 Connections The primary Connection Manager is set up as SSISAutomation and points to the local instance of the SSISDB database. Additional connection managers should reflect type and name (if possible). 5

3.2.3 Expressions/Variables Extensive use of variables should be made to increase portability between environments. Server names, file locations, email addresses, etc. should be configured at the earliest possible time. All variables used in an SSIS package should be listed in a comment on the Control Flow of the package with an explanation of the variable and how and where it is used in the package. In addition, any object using expressions should have the expressions listed in a comment on the Control Flow with the object name and what value of the object is being set by the expression. 6