Book Image

What's New in SQL Server 2012

Book Image

What's New in SQL Server 2012

Overview of this book

Microsoft SQL Server has been part of the enterprise database landscape since SQL Server 7 arrived in 1998 and has evolved into the relational and BI platform of choice by businesses around the globe. The performance and full feature set of SQL Server has been widely recognized by the business community and it is viewed as a powerful weapon in their database and business intelligence arsenal. SQL Server brings numerous benefits to all businesses, central to which is a thorough understanding of the technology, both current and new.This is the book both DBAs and developers always wanted to buy but could never find in the bookstore. This is a SQL Server book that contains only the new features introduced in SQL Server 2012.This book will give you a competitive advantage by helping you to quickly learn and understand the new features of SQL Server 2012. Most readers will already have an established knowledge of SQL Server and will want to update their 2008/2008R2 knowledge swiftly with least pain.This book takes you through all of the new features of SQL Server 2012, from installing core database services and features, to the new administration and updated Transact-SQL functions. You will discover the new Analysis Services features, introduce data alerts and reporting features and explore the new enhancements to Integration Services. In addition you will learn how to automate, cleanse and transform critical business data with DQS and world-class enterprise level availability features.Finally, you will venture into simulating real-world database loads using Distributed Replay and complete your journey with a look at the new SQL Server cloud services and the new Hadoop big data platform.
Table of Contents (19 chapters)
What's New in SQL Server 2012
Credits
About the Authors
Acknowledgment
Acknowledgment
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Installing SQL Server 2012
Index

OFFSET and FETCH


OFFSET and FETCH are two new clauses introduced in SQL erver 2012. Used together in your queries, they allow you to extract a portion of rows from your result set.

We will look at typical SELECT query which you can run against the AdventureWorks database and add in ORDER BY clause.

SELECT BusinessEntityID, FirstName, MiddleName, LastName
FROM [Person].[Person]
ORDER BY BusinessEntityID

The following result set would be returned:

The query returns over 19,000 rows. However, what if you wanted to retrieve just a selection of rows from within that result set and using the SELECT TOP statement doesn't deliver the record you need? In comes the combination of OFFSET and FETCH. Take a look at the following query:

SELECT BusinessEntityID, FirstName, MiddleName, LastName
FROM [Person].[Person]
ORDER BY BusinessEntityID
OFFSET 100 ROWS
FETCH NEXT 5 ROWS ONLY

Here, the OFFSET tells the query to ignore the first 100 rows and then return only the following five rows. This is very easy to...