T-SQL insiders help you tackle your toughest queries and query-tuning problems Squeeze maximum performance and efficiency from every T-SQL query you write or tune. Four leading experts take an in-depth look at T-SQL’s internal architecture and offer advanced practical techniques for optimizing response time and resource usage. Emphasizing a correct understanding of the language and its foundations, the authors present unique solutions they have spent years developing and refining. All code and techniques are fully updated to reflect new T-SQL enhancements in Microsoft SQL Server 2014 and SQL Server 2012. Write faster, more efficient T-SQL code: Move from procedural programming to the language of sets and logic Master an efficient top-down tuning methodology Assess algorithmic complexity to predict performance Compare data aggregation techniques, including new grouping sets Efficiently perform data-analysis calculations Make the most of T-SQL’s optimized bulk import tools Avoid date/time pitfalls that lead to buggy, poorly performing code Create optimized BI statistical queries without additional software Use programmable objects to accelerate queries Unlock major performance improvements with In-Memory OLTP Master useful and elegant approaches to manipulating graphs About This Book For experienced T-SQL practitioners Includes coverage updated from Inside Microsoft SQL Server 2008 T-SQL Querying and Inside Microsoft SQL Server 2008 T-SQL Programming Valuable to developers, DBAs, BI professionals, and data scientists Covers many MCSE 70-464 and MCSA/MCSE 70-461 exam topics
Apply powerful window functions in T-SQL—and increase the performance and speed of your queries Optimize your queries—and obtain simple and elegant solutions to a variety of problems—using window functions in Transact-SQL. Led by T-SQL expert Itzik Ben-Gan, you’ll learn how to apply calculations against sets of rows in a flexible, clear, and efficient manner. Ideal whether you’re a database administrator or developer, this practical guide demonstrates ways to use more than a dozen T-SQL querying solutions to address common business tasks. Discover how to: Go beyond traditional query approaches to express set calculations more efficiently Delve into ordered set functions such as rank, distribution, and offset Implement hypothetical set and inverse distribution functions in standard SQL Use strategies for improving sequencing, paging, filtering, and pivoting Increase query speed using partitioning, ordering, and coverage indexing Apply new optimization iterators such as Window Spool Handle common issues such as running totals, intervals, medians, and gaps
Gain a solid understanding of T-SQL—and write better queries Master the fundamentals of Transact-SQL—and develop your own code for querying and modifying data in Microsoft SQL Server 2012. Led by a SQL Server expert, you’ll learn the concepts behind T-SQL querying and programming, and then apply your knowledge with exercises in each chapter. Once you understand the logic behind T-SQL, you’ll quickly learn how to write effective code—whether you’re a programmer or database administrator. Discover how to: Work with programming practices unique to T-SQL Create database tables and define data integrity Query multiple tables using joins and subqueries Simplify code and improve maintainability with table expressions Implement insert, update, delete, and merge data modification strategies Tackle advanced techniques such as window functions, pivoting and grouping sets Control data consistency using isolation levels, and mitigate deadlocks and blocking Take T-SQL to the next level with programmable objects
Master the foundations of T-SQL with the right balance of conceptual and practical content. Get hands-on guidance—including exercises and code samples—that show you how to develop code to query and modify data. You’ll gain a solid understanding of the T-SQL language and good programming practices, and learn to write more efficient and powerful queries. Discover how to: Apply T-SQL fundamentals, create tables, and define data integrity Understand logical query processing Query multiple tables using joins and subqueries Simplify code and improve maintainability with table expressions Explore pivoting techniques and how to handle grouping sets Write code that modifies data Isolate inconsistent data and address deadlock and blocking scenarios
Take a detailed look at the internal architecture of T-SQL--and unveil the power of set-based querying--with comprehensive reference and advice from the experts. Database developers and administrators get best practices, sample databases, and code to master the intricacies of the programming language--solving complex problems with real-world solutions. Discover how to: Understand logical and physical query processing Apply a methodology to optimize query tuning Solve relational division problems Use CTEs and ranking functions to simplify and optimize solutions Aggregate data with various techniques, including tiebreakers, pivoting, histograms, and grouping factors Use the TOP option in a query to modify data Query specialized data structures with recursive logic, materialized path, or nested sets solutions PLUS--Improve your logic and get to the heart of querying problems with logic puzzles Get code and database samples on the Web
Get a detailed look at the internal architecture of T-SQL with this comprehensive programming reference. Database developers and administrators get best practices, expert techniques, and code samples to master the intricacies of this programming language—solving complex problems with real-world solutions. Discover how to: Work with T-SQL and CLR user-defined functions, stored procedures, and triggers. Handle transactions, concurrency, and error handling. Efficiently use temporary objects, including temporary tables, table variables, and table expressions. Evaluate when to use set-based programming techniques and when to use cursors. Work with dynamic SQL in an efficient and secure manner. Treat date- and time-related data in a robust manner. Develop CLR user-defined types and learn about temporal support in the relational model. Use XML and XQuery and implement a dynamic schema solution. Work with spatial data using the new geometry and geography types and spatial indexes. Track access and changes to data using extended events, SQL Server Audit, change tracking, and change data capture. Use Service Broker for controlled asynchronous processing in database applications. All the book’s code samples will be available for download from the companion Web site.
Effectively query and modify data using Transact-SQL Master T-SQL fundamentals and write robust code for Microsoft SQL Server and Azure SQL Database. Itzik Ben-Gan explains key T-SQL concepts and helps you apply your knowledge with hands-on exercises. The book first introduces T-SQL’s roots and underlying logic. Next, it walks you through core topics such as single-table queries, joins, subqueries, table expressions, and set operators. Then the book covers more-advanced data-query topics such as window functions, pivoting, and grouping sets. The book also explains how to modify data, work with temporal tables, and handle transactions, and provides an overview of programmable objects. Microsoft Data Platform MVP Itzik Ben-Gan shows you how to: Review core SQL concepts and its mathematical roots Create tables and enforce data integrity Perform effective single-table queries by using the SELECT statement Query multiple tables by using joins, subqueries, table expressions, and set operators Use advanced query techniques such as window functions, pivoting, and grouping sets Insert, update, delete, and merge data Use transactions in a concurrent environment Get started with programmable objects–from variables and batches to user-defined functions, stored procedures, triggers, and dynamic SQL
Ace your preparation for Microsoft® Certification Exam 70-461 with this 2-in-1 Training Kit from Microsoft Press®. Work at your own pace through a series of lessons and practical exercises, and then assess your skills with practice tests on CD—featuring multiple, customizable testing options. Maximize your performance on the exam by learning how to: Create database objects Work with data Modify data Troubleshoot and optimize queries You also get an exam discount voucher—making this book an exceptional value and a great career investment.
Your essential guide to key programming features in Microsoft SQL Server 2012 Take your database programming skills to a new level—and build customized applications using the developer tools introduced with SQL Server 2012. This hands-on reference shows you how to design, test, and deploy SQL Server databases through tutorials, practical examples, and code samples. If you’re an experienced SQL Server developer, this book is a must-read for learning how to design and build effective SQL Server 2012 applications. Discover how to: Build and deploy databases using the SQL Server Data Tools IDE Query and manipulate complex data with powerful Transact-SQL enhancements Integrate non-relational features, including native file streaming and geospatial data types Consume data with Microsoft ADO.NET, LINQ, and Entity Framework Deliver data using Windows Communication Foundation (WCF) Data Services and WCF RIA Services Move your database to the cloud with Windows Azure SQL Database Develop Windows Phone cloud applications using SQL Data Sync Use SQL Server BI components, including xVelocity in-memory technologies
Expert T-SQL Window Functions in SQL Server takes you from any level of knowledge of windowing functions and turns you into an expert who can use these powerful functions to solve many T-SQL queries. Replace slow cursors and self-joins with queries that are easy to write and fantastically better performing, all through the magic of window functions. First introduced in SQL Server 2005, window functions came into full blossom with SQL Server 2012. They truly are one of the most notable developments in SQL in a decade, and every developer and DBA can benefit from their expressive power in solving day-to-day business problems. Begin using windowing functions like ROW_NUMBER and LAG, and you will discover more ways to use them every day. You will approach SQL Server queries in a different way, thinking about sets of data instead of individual rows. Your queries will run faster, they will be easier to write, and they will be easier to deconstruct and maintain and enhance in the future. Just knowing and using these functions is not enough. You also need to understand how to tune the queries. Expert T-SQL Window Functions in SQL Server explains clearly how to get the best performance. The book also covers the rare cases when older techniques are the best bet. Stop using cursors and self-joins to solve complicated queries. Become a T-SQL expert by mastering windowing functions. Teaches you how to use all the window functions introduced in 2005 and 2012. Provides real-world examples that you can experiment with in your own database. Explains how to get the best performance when using windowing functions.
Beginning T-SQL is a performance-oriented introduction to the T-SQL language underlying the Microsoft SQL Server database engine. T-SQL is essential in writing SQL statements to get data into and out of a database. T-SQL is the foundation for business logic embedded in the database in the form of stored procedures and functions. Beginning T-SQL starts you on the path to mastering T-SQL, with an emphasis on best-practices and sound coding techniques leading to excellent performance. This new edition is updated to cover the essential features of T-SQL found in SQL Server 2014, 2012, and 2008. Beginning T-SQL begins with an introduction to databases, normalization, and to SQL Server Management Studio. Attention is given to Azure SQL Database and how to connect to remote databases in the cloud. Each subsequent chapter teaches an aspect of T-SQL, building on the skills learned in previous chapters. Exercises in most chapters provide an opportunity for the hands-on practice that leads to true learning and distinguishes the competent professional. Important techniques such as windowing functions are covered to help write fast executing queries that solve real business problems. A stand-out feature in this book is that most chapters end with a "Thinking About Performance" section. These sections cover aspects of query performance relative to the content just presented. They'll help you avoid beginner mistakes by knowing about and thinking about performance from Day 1. Imparts best practices for writing T-SQL Helps you avoid common errors Shows how to write scalable code for good performance
Dive deep inside the architecture of SQL Server 2012 Explore the core engine of Microsoft SQL Server 2012—and put that practical knowledge to work. Led by a team of SQL Server experts, you’ll learn the skills you need to exploit key architectural features. Go behind the scenes to understand internal operations for creating, expanding, shrinking, and moving databases—whether you’re a database developer, architect, or administrator. Discover how to: Dig into SQL Server 2012 architecture and configuration Use the right recovery model and control transaction logging Reduce query execution time through proper index design Track events, from triggers to the Extended Event Engine Examine internal structures with database console commands Transcend row-size limitations with special storage capabilities Choose the right transaction isolation level and concurrency model Take control over query plan caching and reuse
Prepare for Microsoft Exam 70-761–and help demonstrate your real-world mastery of SQL Server 2016 Transact-SQL data management, queries, and database programming. Designed for experienced IT professionals ready to advance their status, Exam Ref focuses on the critical-thinking and decision-making acumen needed for success at the MCSA level. Focus on the expertise measured by these objectives: • Filter, sort, join, aggregate, and modify data • Use subqueries, table expressions, grouping sets, and pivoting • Query temporal and non-relational data, and output XML or JSON • Create views, user-defined functions, and stored procedures • Implement error handling, transactions, data types, and nulls This Microsoft Exam Ref: • Organizes its coverage by exam objectives • Features strategic, what-if scenarios to challenge you • Assumes you have experience working with SQL Server as a database administrator, system engineer, or developer • Includes downloadable sample database and code for SQL Server 2016 SP1 (or later) and Azure SQL Database Querying Data with Transact-SQL About the Exam Exam 70-761 focuses on the skills and knowledge necessary to manage and query data and to program databases with Transact-SQL in SQL Server 2016. About Microsoft Certification Passing this exam earns you credit toward a Microsoft Certified Solutions Associate (MCSA) certification that demonstrates your mastery of essential skills for building and implementing on-premises and cloud-based databases across organizations. Exam 70-762 (Developing SQL Databases) is also required for MCSA: SQL 2016 Database Development certification. See full details at: microsoft.com/learning
SQL Server T-SQL Recipes is an example-based guide to the Transact-SQL language that is at the core of SQL Server. This edition has been lightly updated for SQL Server 2014 and provides ready-to-implement solutions to common programming and database administration tasks. Learn to create databases, create in-memory tables and stored procedures, insert and update data, generate reports, secure your data, and more. Tasks and their solutions are broken down into a problem/solution format that is quick and easy to read so that you can get the job done fast when the pressure is on. Solutions in this book are divided into chapters by problem domain. Each chapter is a collection of solutions around a single facet of the language such as writing queries, managing indexes, error handling, and query performance. Each solution is presented code-first, giving you a working code example to copy from and implement immediately in your own environment. Following each example is an in-depth description of how and why the given solution works. Tradeoffs and alternative approaches are also discussed. Focused on solutions: Look up what you need to do. Learn how to do it. Do it. Current: Lightly updated for SQL Server 2014 Comprehensive: Covers all common T-SQL problem domains