Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes offers straightforward, practical answers when you need fast results. By working through 10-minute lessons, you’ll learn everything 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, and much more. You’ll learn what you need to know methodically, systematically, and simply–in highly focused lessons designed to make you immediately and effortlessly productive. Tips point out shortcuts and solutions Cautions help you avoid common pitfalls Notes explain additional concepts, and provide additional information 10 minutes is all you need to 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 Register your book at www.samspublishing.com/register to download examples and source code from this book.
Author(s): Ben Forta
Edition: 1
Year: 2007
Language: English
Pages: 368
Sams Teach Yourself Microsoft® SQL Server T-SQL in 10 Minutes......Page 1
Table of Contents......Page 4
Introduction......Page 16
Companion Website......Page 17
Conventions Used in This Book......Page 18
Database Basics......Page 20
What Is SQL?......Page 26
Summary......Page 27
What Is SQL Server?......Page 28
SQL Server Tools......Page 31
Summary......Page 33
Making the Connection......Page 34
Selecting a Database......Page 35
Learning About Databases and Tables......Page 36
Summary......Page 40
Retrieving Individual Columns......Page 42
Retrieving Multiple Columns......Page 44
Retrieving All Columns......Page 46
Retrieving Distinct Rows......Page 47
Limiting Results......Page 48
Summary......Page 51
Sorting Data......Page 52
Sorting by Multiple Columns......Page 54
Specifying Sort Direction......Page 55
Summary......Page 58
Using the WHERE Clause......Page 60
The WHERE Clause Operators......Page 61
Summary......Page 67
Combining WHERE Clauses......Page 68
Using the IN Operator......Page 72
Using the NOT Operator......Page 74
Summary......Page 75
Using the LIKE Operator......Page 76
Summary......Page 82
Understanding Calculated Fields......Page 84
Concatenating Fields......Page 85
Performing Mathematical Calculations......Page 90
Summary......Page 92
Understanding Functions......Page 94
Using Functions......Page 95
Summary......Page 104
Using Aggregate Functions......Page 106
Aggregates on Distinct Values......Page 113
Summary......Page 115
Understanding Data Grouping......Page 116
Creating Groups......Page 117
Filtering Groups......Page 118
Grouping and Sorting......Page 121
SELECT Clause Ordering......Page 123
Summary......Page 124
Filtering by Subquery......Page 126
Using Subqueries as Calculated Fields......Page 131
Checking for Existence with Subqueries......Page 134
Summary......Page 136
Understanding Joins......Page 138
Creating a Join......Page 141
Summary......Page 150
Using Table Aliases......Page 152
Using Different Join Types......Page 153
Using Joins with Aggregate Functions......Page 160
Summary......Page 162
Understanding Combined Queries......Page 164
Creating Combined Queries......Page 165
Summary......Page 170
Understanding Full-Text Searching......Page 172
Setting Up Full-Text Searching......Page 173
Performing Full-Text Searches......Page 177
Summary......Page 185
Understanding Data Insertion......Page 186
Inserting Complete Rows......Page 187
Inserting Multiple Rows......Page 191
Inserting Retrieved Data......Page 192
Summary......Page 194
Updating Data......Page 196
Deleting Data......Page 198
Guidelines for Updating and Deleting Data......Page 199
Summary......Page 200
Creating Tables......Page 202
Updating Tables......Page 210
Deleting Tables......Page 212
Summary......Page 213
Understanding Views......Page 214
Using Views......Page 216
Summary......Page 223
Understanding T-SQL Programming......Page 224
Using Variables......Page 225
Using Conditional Processing......Page 232
Grouping Statements......Page 234
Using Looping......Page 236
Summary......Page 237
Understanding Stored Procedures......Page 238
Why Use Stored Procedures......Page 239
Using Stored Procedures......Page 240
Summary......Page 249
Working with Cursors......Page 250
Summary......Page 257
Understanding Triggers......Page 258
Using Triggers......Page 262
Summary......Page 265
Understanding Transaction Processing......Page 266
Controlling Transactions......Page 268
Summary......Page 273
Understanding SQL Server XML Support......Page 274
Retrieving Data as XML......Page 275
Storing XML Data......Page 279
Searching for XML Data......Page 282
Summary......Page 283
Understanding Character Sets and Collation Sequences......Page 284
Working with Collation Sequences......Page 285
Managing Case Sensitivity......Page 288
Working with Unicode......Page 290
Summary......Page 292
Understanding Access Control......Page 294
Managing Users......Page 296
Managing Access Rights......Page 298
Summary......Page 300
Improving Performance......Page 302
Summary......Page 304
What You’ll Need......Page 306
Installing the Software......Page 307
Preparing for Your Lessons......Page 308
Understanding the Example Tables......Page 310
Creating the Example Tables......Page 315
BEGIN TRANSACTION......Page 318
CREATE INDEX......Page 319
CREATE TABLE......Page 320
INSERT......Page 321
SAVE TRANSACTION......Page 322
UPDATE......Page 323
D: T-SQL Datatypes......Page 324
String Datatypes......Page 325
Numeric Datatypes......Page 326
Date and Time Datatypes......Page 327
Other Datatypes......Page 328
E: T-SQL Reserved Words......Page 330
A......Page 336
B......Page 337
C......Page 338
D......Page 340
F......Page 342
G......Page 344
J......Page 345
L......Page 346
N......Page 347
P......Page 348
Q......Page 349
R......Page 350
S......Page 351
T......Page 357
U......Page 358
W......Page 359
X-Z......Page 360