TOP10 DEV SKILLS TO MAKE YOUR DBA HAPPY Kevin Kline Director of Engineering Services, SQL Sentry SQL Server MVP since 2004 Twitter, FB, LI: KEKline Blog:

Slides:



Advertisements
Similar presentations
Chapter 9. Performance Management Enterprise wide endeavor Research and ascertain all performance problems – not just DBMS Five factors influence DB performance.
Advertisements

Kevin Kline Director of Engineering Services, SQL Sentry SQL Server MVP since 2003 Twitter, FB, LI: KEKline Blog:
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.
Connect with life Vinod Kumar M Technology Evangelist | Microsoft
Managing Concurrency in Web Applications. DBI 2007 HUJI-CS 2 Intersection of Concurrent Accesses A fundamental property of Web sites: Concurrent accesses.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Kevin Kline, SQL Sentry Director of Engineering Services, Microsoft SQL Server MVP since 2003 Twitter, Facebook, KEKline.
Stored Procedures Dr. Ralph D. Westfall May, 2009.
Overview What is SQL Server? Creating databases Administration Security Backup.
How a little code can help with support.. Chris Barba – Developer at Cimarex Energy Blog:
Database Design for DNN Developers Sebastian Leupold.
Beginning Databases with JDBC Mike Bradley Adapted from and notes by Kevin Parker, Ph.D.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
SQL Server 2008 for Developers John
T-SQL : Bad Habits to Kick Aaron Bertrand SQL Sentry, Inc.
ADO.NET A2 Teacher Up skilling LECTURE 3. What’s to come today? ADO.NET What is ADO.NET? ADO.NET Objects SqlConnection SqlCommand SqlDataReader DataSet.
© 2010 Quest Software, Inc. ALL RIGHTS RESERVED Top 10 Admin Mistakes on Microsoft SQL Server Kevin Kline, Quest Software Microsoft MVP since 2004.
DBSQL 14-1 Copyright © Genetic Computer School 2009 Chapter 14 Microsoft SQL Server.
PART 1 CREATING THE PRODUCT CATALOG. ROADMAP FOR THIS CHAPTER To implement the departments list, you’ll start with the database and make your way to the.
Stored Procedures, Transactions, and Error-Handling
Neal Stublen Populating a Database  SQLExpress should be installed with Visual Studio  The book provides a.sql file for populating.
ADO.Net CS795. What is ADO.Net? Database language spoken by managed applications ADO.net database accesses go through modules: data providers –SQL Server.Net.
Agenda for Today Do Chapter 14 Final Project Review for Final.
1cs Intersection of Concurrent Accesses A fundamental property of Web sites: Concurrent accesses by multiple users Concurrent accesses intersect.
Learningcomputer.com SQL Server 2008 – Profiling and Monitoring Tools.
11 Using ADO.NET II Textbook Chapter Getting Started Last class we started a simple example of using ADO.NET operations to access the Addresses.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL ADO.Net Basics Ruwan Wijesinghe Trainer.
Module 8: Implementing Stored Procedures. Overview Implementing Stored Procedures Creating Parameterized Stored Procedures Working With Execution Plans.
SQL Dev Tips for Small Workstations How to develop SQL on small dev workstations when prod is huge. Kevin Kline and Aaron Bertrand SQL Sentry.
Module 3: Performing Connected Database Operations.
Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,
1 11/10/05CS360 Windows Programming ADO.NET. 2 11/10/05CS360 Windows Programming ADO.NET  Behind every great application is a database manager o Amazon.
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM SQL Server 2005 Performance Diagnosis and Tuning using SQL Tools.
SQL School is strongly committed to provide COMPLETE PRACTICAL REALTIME Trainings on SQL Server Technologies – Dev, SQL DBA, MSBI (SSIS, SSAS, SSRS) and.
ADO.Net CS795. What is ADO.Net? Database language spoken by managed applications ADO.net database accesses go through modules: data providers –SQL Server.Net.
SQLintersection Understanding Transaction Isolation Levels Randy Knight Wednesday, 3:45-5:00.
1 Intro stored procedures Declaring parameters Using in a sproc Intro to transactions Concurrency control & recovery States of transactions Desirable.
Module 11: Managing Transactions and Locks
IMS 4212: Constraints & Triggers 1 Dr. Lawrence West, Management Dept., University of Central Florida Stored Procedures in SQL Server.
Module 14: Managing Transactions and Locks. Overview Introducing Transactions and Locks Managing Transactions Understanding SQL Server Locking Architecture.
Database Systems, 8 th Edition SQL Performance Tuning Evaluated from client perspective –Most current relational DBMSs perform automatic query optimization.
Copyright Sammamish Software Services All rights reserved. 1 Prog 140  SQL Server Performance Monitoring and Tuning.
Common SQL Performance Issues AND HOW TO AVOID OR FIX THEM.
1 Section 10 - Embedded SQL u Many computer languages allow you to embed SQL statements within the code (e.g. COBOL, PowerBuilder, C++, PL/SQL, etc.) u.
Scott Fallen Sales Engineer, SQL Sentry Blog: scottfallen.blogspot.com.
Kevin Kline Director of Engineering Services, SQL Sentry SQL Server MVP since 2003 Twitter, FB, LI: KEKline Blog:
Introduction to SQL Server Automation with Powershell by Chris Sommer.
SQL Advanced Monitoring Using DMV, Extended Events and Service Broker Javier Villegas – DBA | MCP | MCTS.
.NET Data Access and Manipulation
In this session, you will learn to: Create and manage views Implement a full-text search Implement batches Objectives.
ELASTIC DATABASE CAPABILITIES WITH AZURE SQL DB Silvia Doomra Azure SQL DB Program Management.
Kevin Kline Director of Engineering Services, SQL Sentry SQL Server MVP since 2003 Twitter, FB, LI: KEKline Blog:
Honest Bob’s Cube Processing Bob Duffy Database Architect.
Ten 10 Things DBAs Want.NET Developers to Know Kevin Kline Technical Strategy Manager, Quest
SQLSTARTER - INTRO TO DATABASE DEVELOPMENT Kevin Kline Technical Evangelist, SQL Sentry SQL Server MVP since 2003 Twitter, FB, LI, KEKline Blog:
ASP.NET Programming with C# and SQL Server First Edition
SQL Server 2012 AlwaysOn and SQLSentry
Isolation Levels Understanding Transaction Temper Tantrums
Purpose, Pitfalls and Performance Implications
Purpose, Pitfalls and Performance Implications
Top Tips for Better TSQL Stored Procedures
On transactions, and Atomic Operations
Transactions, Locking and Query Optimisation
Crash course on Better SQL Development
Understanding Transaction Isolation Levels
On transactions, and Atomic Operations
SQL Server Query Design and Optimization Recommendations
Isolation Levels Understanding Transaction Temper Tantrums
Using wait stats to determine why my server is slow
Presentation transcript:

TOP10 DEV SKILLS TO MAKE YOUR DBA HAPPY Kevin Kline Director of Engineering Services, SQL Sentry SQL Server MVP since 2004 Twitter, FB, LI: KEKline Blog:

SQLSentry.net Agenda ToolsTechniques Process, Patterns & Practices Happy & Helpful DBA!

SQLSentry.net #1. Tools: Everybody’s Best Friend Books Online Regular updates available Microsoft® SQL Server™ Management Studio (SSMS) Query plans Object scripting Quick and dirty data browsing Good source control integration

SQLSentry.net #2. Execution Plans and Traces SQL Server processes a query through an execution plan aka a query plan Learn how to compare in SSMS Learn how to watch it happen with SQL Profiler Query performance may be misleading Should evaluate on comparable data sizes Different CPU, Disk, caching, etc. Evaluate the query “Cost”

SQLSentry.net TECHNIQUES

SQLSentry.net #3. Test Harness & Testing Clear your caches Measure: Total elapsed time Individual statement time IO load Facilitates automation of execution plans Get to know the DMV sys.dm_exec_query_stats

SQLSentry.net #4. Query Performance Tips Indexes! Statistics! WHERE clauses: Don’t put a function around an indexed column Can ensure or prevent index usage Use EXISTS to check for existence Be careful: NOT IN clauses Temp variables User-defined functions

SQLSentry.net #5. Sets Versus Rows Microsoft® Visual C#®, Visual Basic®, Visual C++®, etc. are procedural languages Tell the computer what to do SQL is a declarative language Tell the computer what you want Learn to think in terms of sets: One pass through a table Let the computer process joins and filters Loops and cursors for specific use-cases only

SQLSentry.net #6. Connecting to SQL Server Use the SqlClient namespace in Microsoft®.NET Use Connection Pooling On by default in.NET Set Application Name in connection string Helps troubleshooting and monitoring Slightly degrades connection pooling SqlDataReaders are much faster than DataTables Update through stored procedures or SQL statements

SQLSentry.net Example Code to Set the App Name SqlConnectionStringBuilder csb = new SqlConnectionStringBuilder(); csb.DataSource = “L40\YUKON”; csb.IntegratedSecurity = true; csb.InitialCatalog = "AdventureWorks"; csb.ApplicationName = "MyDemoApp"; string connectionString = csb.ToString(); SqlConnection conn = new SqlConnection(); conn.ConnectionString Source=L40\YUKON; Initial Catalog=AdventureWorks; Integrated Security=True; Application Name=MyDemoApp”;

SQLSentry.net #7. Handling Nulls NULLs = ? ANSI SQL-92 requires any comparison to a NULL to fail (i.e. false) This is SET ANSI_NULLS ON default setting NULL = NULL returns false NULL NULL returns false ANSI_NULLS OFF WHERE NULL = NULL returns true How do I know when I don’t know what I know, y’know?

SQLSentry.net Handling Nulls Use WHERE ColumnName IS NULL Avoid WHERE ColumnName = NULL WHERE Col) WHERE IS NULL OR

SQLSentry.net Nulls on the Client Basic types (int, string, etc.) don’t handle Null SqlDataReader IsDBNull tests whether a column is null DataColumn AllowDBNull property System.DBNull.Value Populate SqlParameters Nullable types (int?, string?, etc.) do handle Null Really just Nullable Any type can be declared nullable

SQLSentry.net Nullable Types Classes (types) that support Null Use IsDBNull to check database for NULL string? s; Console.WriteLine(s.HasValue.ToString()); s = “Test”; string? x = null;

SQLSentry.net #8. Transactions and Error Handling Ability to consume T-SQL errors Can nest TRY…CATCH blocks Used in the CATCH block Preventing Errors Use EXISTS() to check for rows Use a return code to signify failure

SQLSentry.net Client-Side Error Handling Catch a SqlException Check the Errors collection for multiple errors try { SqlDataReader r = cmd.ExecuteReader(); } catch (SqlException ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.Errors.Count.ToString()); }

SQLSentry.net Transactions COMMIT TRAN matches BEGIN TRAN ROLLBACK TRAN cancels ALL transactions Always BEGIN, COMMIT, and ROLLBACK transactions at a consistent level Always test prior to COMMIT or ROLLBACK

SQLSentry.net Client-Side Transactions SqlConnection conn = new SqlConnection(“…") ; conn.Open(); SqlTransaction trans = conn.BeginTransaction(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.Transaction = trans; try { // do some stuff trans.Commit(); } catch (SqlException) { trans.Rollback(); }

SQLSentry.net PATTERNS & PRACTICES

SQLSentry.net #9. Security is NOT an Afterthought SQL Injection is ________________________________. Plan ahead of time to minimize issues: Ensure the least privileges principle for applications running on your servers How much surface area do your servers expose? Who has access to your servers? How do you find out the who, what, and when of a breach?

SQLSentry.net #10. Change Management is RISK Management Understand what the job entails and what makes a DBA successful! Change control is important! Without it, DBAs face: Changes that leave things worse than they started Piecemeal rollbacks that cripple applications Inconsistent support across applications and servers Proper change management means: Processed by a “change management board” composed of all key stakeholders Performed at pre-planned times and within a defined time limit Change is tested and verified to have no effect or positive effect on production environment Changes are isolated, atomic, and reversible 21

SQLSentry.net Additional Resources Plan Explorer Free: server-query-view.asphttp://sqlsentry.net/plan-explorer/sql- server-query-view.asp Twitter and #SQLHelp SQLCAT.com SQLSkills.com Community Sites: SQLPASS.org SQLServerCentral.com SQLBlog.com SQLServerFAQ.com

SQLSentry.net SUMMARY SSMS, Traces, and Execution Plans Test Harness & Testing Query Tuning Tips Temp tables Cursors & Loops NULL Error Handling Transactions Security isn’t an afterthought Change Management is risk management

SQLSentry.net Q & A Send questions to me at: Twitter, Facebook, LinkedIn at KEKline Slides at IT Leadership content at THANK YOU!