Sams Teach Yourself Microsoft® SQL Server T-SQL in 10 Minutes, Second Edition

Book description

Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes offers straightforward, practical answers when you need fast results. By working through the book’s 30 lessons of 10 minutes or less, you’ll learn what you need to know to take advantage of Microsoft SQL Server’s T-SQL language.

This handy pocket guide starts with simple data retrieval and moves on to more complex topics, including the use of joins, subqueries, full text-based searches, functions and stored procedures, cursors, triggers, table constraints, XML, JSON, and much more.

Learn how to…

  • Use T-SQL in the Microsoft SQL Server environment

  • Construct complex T-SQL statements using multiple clauses and operators

  • Filter data so you get the information you need quickly

  • Retrieve, sort, and format database contents

  • Join two or more related tables

  • Make SQL Server work for you with globalization and localization

  • Create subqueries to pinpoint your data

  • Automate your workload with triggers

  • Create and alter database tables

  • Work with views, stored procedures, and more

  • Contents at a Glance

  • 1 Understanding SQL

  • 2 Introducing SQL Server

  • 3 Working with SQL Server

  • 4 Retrieving Data

  • 5 Sorting Retrieved Data

  • 6 Filtering Data

  • 7 Advanced Data Filtering

  • 8 Using Wildcard Filtering

  • 9 Creating Calculated Fields

  • 10 Using Data Manipulation Functions

  • 11 Summarizing Data

  • 12 Grouping Data

  • 13 Working with Subqueries

  • 14 Joining Tables

  • 15 Creating Advanced Joins

  • 16 Combining Queries

  • 17 Full-Text Searching

  • 18 Inserting Data

  • 19 Updating and Deleting Data

  • 20 Creating and Manipulating Tables

  • 21 Using Views

  • 22 Programming with T-SQL

  • 23 Working with Stored Procedures

  • 24 Using Cursors

  • 25 Using Triggers

  • 26 Managing Transaction Processing

  • 27 Working with XML and JSON

  • 28 Globalization and Localization

  • 29 Managing Security

  • 30 Improving Performance

  • A The Example Tables

  • B T-SQL Statement Syntax

  • C T-SQL Datatypes

  • D T-SQL Reserved Words

  • Table of contents

    1. About This E-Book
    2. Title Page
    3. Copyright Page
    4. Accessing the Free Web Edition
    5. Contents
    6. About the Author
    7. We Want to Hear from You!
    8. Introduction
      1. Who Is This Book For?
      2. Companion Website
      3. Conventions Used in This Book
    9. Lesson 1. Understanding SQL
      1. Database Basics
        1. What Is a Database?
        2. Tables
        3. Columns and Datatypes
        4. Rows
        5. Primary Keys
      2. What Is SQL?
      3. Try It Yourself
      4. Summary
    10. Lesson 2. Introducing SQL Server
      1. What Is SQL Server?
        1. Client Server Software
        2. SQL Server Versions
        3. SQL Server Tools
      2. Getting Started with SQL Server and T-SQL
        1. Getting Access To a Server
        2. Obtaining the Software
        3. Installing the Software
      3. Preparing for Your Lessons
      4. Summary
    11. Lesson 3. Working with SQL Server
      1. Making the Connection
      2. Navigating SQL Server Management Studio
      3. Creating the Example Tables
      4. Selecting a Database
      5. Learning About Databases and Tables
      6. Summary
    12. Lesson 4. Retrieving Data
      1. The SELECT Statement
      2. Retrieving Individual Columns
      3. Retrieving Multiple Columns
      4. Retrieving All Columns
      5. Retrieving Distinct Rows
      6. Limiting Results
      7. Using Fully Qualified Table Names
      8. Summary
    13. Lesson 5. Sorting Retrieved Data
      1. Sorting Data
      2. Sorting by Multiple Columns
      3. Specifying Sort Direction
      4. Summary
    14. Lesson 6. Filtering Data
      1. Using the WHERE Clause
      2. The WHERE Clause Operators
        1. Checking Against a Single Value
        2. Checking for Nonmatches
        3. Checking for a Range of Values
        4. Checking for No Value
      3. Summary
    15. Lesson 7. Advanced Data Filtering
      1. Combining WHERE Clauses
        1. Using the AND Operator
        2. Using the OR Operator
        3. Understanding Order of Evaluation
      2. Using the IN Operator
      3. Using the NOT Operator
      4. Summary
    16. Lesson 8. Using Wildcard Filtering
      1. Using the LIKE Operator
        1. The Percent Sign (%) Wildcard
        2. The Underscore (_) Wildcard
        3. The Brackets ([]) Wildcard
      2. Tips for Using Wildcards
      3. Summary
    17. Lesson 9. Creating Calculated Fields
      1. Understanding Calculated Fields
      2. Concatenating Fields
        1. Using Aliases
      3. Performing Mathematical Calculations
      4. Summary
    18. Lesson 10. Using Data Manipulation Functions
      1. Understanding Functions
      2. Using Functions
        1. Text Manipulation Functions
        2. Date and Time Manipulation Functions
        3. Numeric Manipulation Functions
      3. Summary
    19. Lesson 11. Summarizing Data
      1. Using Aggregate Functions
        1. The Avg() Function
        2. The Count() Function
        3. The Max() Function
        4. The Min() Function
        5. The Sum() Function
      2. Aggregates on Distinct Values
      3. Combining Aggregate Functions
      4. Summary
    20. Lesson 12. Grouping Data
      1. Understanding Data Grouping
      2. Creating Groups
      3. Filtering Groups
      4. Grouping and Sorting
      5. SELECT Clause Ordering
      6. Summary
    21. Lesson 13. Working with Subqueries
      1. Understanding Subqueries
      2. Filtering by Subquery
      3. Using Subqueries as Calculated Fields
      4. Checking for Existence with Subqueries
      5. Summary
    22. Lesson 14. Joining Tables
      1. Understanding Joins
        1. Understanding Relational Tables
        2. Why Use Joins?
      2. Creating a Join
        1. The Importance of the WHERE Clause
        2. Inner Joins
        3. Joining Multiple Tables
      3. Summary
    23. Lesson 15. Creating Advanced Joins
      1. Using Table Aliases
      2. Using Different Join Types
        1. Self Joins
        2. Natural Joins
        3. Outer Joins
      3. Using Joins with Aggregate Functions
      4. Using Joins and Join Conditions
      5. Summary
    24. Lesson 16. Combining Queries
      1. Understanding Combined Queries
      2. Creating Combined Queries
        1. Using UNION
        2. UNION Rules
        3. Including or Eliminating Duplicate Rows
        4. Sorting Combined Query Results
      3. Summary
    25. Lesson 17. Full-Text Searching
      1. Understanding Full-Text Searching
      2. Setting Up Full-Text Searching
        1. Enabling Full-Text Searching Support
        2. Creating a Full-Text Catalog
        3. Creating a Full-Text Index
        4. Managing Catalogs and Indexes
      3. Performing Full-Text Searches
        1. Searching Using FREETEXT
        2. Searching Using CONTAINS
        3. Ranking Search Results
      4. Summary
    26. Lesson 18. Inserting Data
      1. Understanding Data Insertion
      2. Inserting Complete Rows
      3. Inserting Multiple Rows
      4. Inserting Retrieved Data
      5. Reporting On Inserted Data
      6. Summary
    27. Lesson 19. Updating and Deleting Data
      1. Updating Data
      2. Deleting Data
      3. Reporting On Updated And Deleted Data
      4. Guidelines for Updating and Deleting Data
      5. Summary
    28. Lesson 20. Creating and Manipulating Tables
      1. Creating Tables
        1. Basic Table Creation
        2. Working with NULL Values
        3. Primary Keys Revisited
        4. Using IDENTITY
        5. Specifying Default Values
      2. Updating Tables
      3. Deleting Tables
      4. Renaming Tables
      5. Summary
    29. Lesson 21. Using Views
      1. Understanding Views
        1. Why Use Views
        2. View Rules and Restrictions
      2. Using Views
        1. Using Views to Simplify Complex Joins
        2. Using Views to Reformat Retrieved Data
        3. Using Views to Filter Unwanted Data
        4. Using Views with Calculated Fields
        5. Updating Views
      3. Summary
    30. Lesson 22. Programming with T-SQL
      1. Understanding T-SQL Programming
      2. Using Variables
        1. Declaring Variables
        2. Assigning Values to Variables
        3. Viewing Variable Contents
        4. Using Variables in T-SQL Statements
      3. Using Conditional Processing
      4. Grouping Statements
      5. Using Looping
      6. Summary
    31. Lesson 23. Working with Stored Procedures
      1. Understanding Stored Procedures
      2. Why Use Stored Procedures
      3. Using Stored Procedures
        1. Executing Stored Procedures
        2. Creating Stored Procedures
        3. Dropping Stored Procedures
        4. Working with Parameters
        5. Building Intelligent Stored Procedures
      4. Summary
    32. Lesson 24. Using Cursors
      1. Understanding Cursors
      2. Working with Cursors
        1. Creating and Removing Cursors
        2. Opening and Closing Cursors
        3. Using Cursor Data
      3. Summary
    33. Lesson 25. Using Triggers
      1. Understanding Triggers
        1. Creating Triggers
        2. Dropping Triggers
        3. Enabling and Disabling Triggers
        4. Determining Trigger Assignments
      2. Using Triggers
        1. INSERT Triggers
        2. DELETE Triggers
        3. UPDATE Triggers
        4. More on Triggers
      3. Summary
    34. Lesson 26. Managing Transaction Processing
      1. Understanding Transaction Processing
      2. Controlling Transactions
        1. Using ROLLBACK
        2. Using COMMIT
        3. Using Savepoints
        4. Changing Autocommit Behavior
      3. Summary
    35. Lesson 27. Working with XML and JSON
      1. Using SQL Server XML Support
        1. Retrieving Data As XML
        2. Storing XML Data
        3. Searching for XML Data
      2. Using SQL Server JSON Support
      3. Retrieving Data as JSON
      4. The JSON Functions
      5. Summary
    36. Lesson 28. Globalization and Localization
      1. Understanding Character Sets and Collation Sequences
      2. Working with Collation Sequences
      3. Managing Case Sensitivity
      4. Working with Unicode
      5. Summary
    37. Lesson 29. Managing Security
      1. Understanding Access Control
      2. Managing Users
        1. Creating User Accounts
        2. Deleting User Accounts
        3. Enabling and Disabling Accounts
        4. Renaming Logins
        5. Changing Passwords
      3. Managing Access Rights
        1. Setting Access Rights
        2. Removing Access Rights
      4. Summary
    38. Lesson 30. Improving Performance
      1. Improving Performance
      2. Summary
    39. Appendix A. The Example Tables
      1. Understanding the Example Tables
        1. Table Descriptions
    40. Appendix B. T-SQL Statement Syntax
      1. BEGIN TRANSACTION
      2. ALTER TABLE
      3. COMMIT TRANSACTION
      4. CREATE INDEX
      5. CREATE LOGIN
      6. CREATE PROCEDURE
      7. CREATE TABLE
      8. CREATE VIEW
      9. DELETE
      10. DROP
      11. INSERT
      12. INSERT SELECT
      13. ROLLBACK TRANSACTION
      14. SAVE TRANSACTION
      15. SELECT
      16. UPDATE
    41. Appendix C. T-SQL Datatypes
      1. String Datatypes
      2. Numeric Datatypes
      3. Date and Time Datatypes
      4. Binary Datatypes
      5. Other Datatypes
    42. Appendix D. T-SQL Reserved Words
    43. Index

    Product information

    • Title: Sams Teach Yourself Microsoft® SQL Server T-SQL in 10 Minutes, Second Edition
    • Author(s): Ben Forta
    • Release date: December 2016
    • Publisher(s): Sams
    • ISBN: 9780134649160