- Page 2 and 3:
Programmer to Programmer Get more
- Page 5:
Beginning Microsoft SQL Ser ver® 2
- Page 8 and 9:
Beginning Microsoft SQL Ser ver® 2
- Page 11:
About the Author Experiencing his f
- Page 15:
Acknowledgments Over the years, the
- Page 18 and 19:
Contents Chapter 2:T ools of the T
- Page 20 and 21:
Contents xviii The CREATE Statement
- Page 22 and 23:
Contents xx Correlated Subqueries 1
- Page 24 and 25:
Contents xxii SORT_IN_TEMPDB 280 ON
- Page 26 and 27:
Contents xxiv Control-of-Flow State
- Page 28 and 29:
Contents xxvi How the SQL Ser ver L
- Page 30 and 31:
Contents Chapter 16: A Brief XML Pr
- Page 32 and 33:
Contents Chapter 19: Pla ying Admin
- Page 34 and 35:
Introduction The beginning user wil
- Page 36 and 37:
Introduction ❏ We show file names
- Page 38 and 39:
Introduction xxxvi ❏ Understand t
- Page 40 and 41:
Chapter 1: RDBMS Basics: What Makes
- Page 42 and 43:
Chapter 1: RDBMS Basics: What Makes
- Page 44 and 45:
Chapter 1: RDBMS Basics: What Makes
- Page 46 and 47:
Chapter 1: RDBMS Basics: What Makes
- Page 48 and 49:
Chapter 1: RDBMS Basics: What Makes
- Page 50 and 51:
Chapter 1: RDBMS Basics: What Makes
- Page 52 and 53:
Chapter 1: RDBMS Basics: What Makes
- Page 54 and 55:
Chapter 1: RDBMS Basics: What Makes
- Page 56 and 57:
Chapter 1: RDBMS Basics: What Makes
- Page 58 and 59:
Chapter 1: RDBMS Basics: What Makes
- Page 60 and 61:
Chapter 2: Tools of the Trade 22 My
- Page 62 and 63:
Chapter 2: Tools of the Trade ❑ S
- Page 64 and 65:
Chapter 2: Tools of the Trade 26 Ke
- Page 66 and 67:
Chapter 2: Tools of the Trade 28 Th
- Page 68 and 69: Chapter 2: Tools of the Trade 30 lo
- Page 70 and 71: Chapter 2: Tools of the Trade 32 3.
- Page 72 and 73: Chapter 2: Tools of the Trade 34 Fi
- Page 74 and 75: Chapter 2: Tools of the Trade Figur
- Page 76 and 77: Chapter 2: Tools of the Trade Note
- Page 78 and 79: Chapter 2: Tools of the Trade bcp i
- Page 81 and 82: 3 The Foundation Statements of T-SQ
- Page 83 and 84: asic SELECT statement. Fire up the
- Page 85 and 86: Now let’s try taking a little bit
- Page 87 and 88: very few of your tables will have s
- Page 89 and 90: Operator Example Usage Effect ALL,
- Page 91 and 92: Chapter 3: The Foundation Statement
- Page 93 and 94: WHERE SalesOrderID IN (43660, 43670
- Page 95 and 96: AVG This one is for computing avera
- Page 97 and 98: efore, but remove the two AS keywor
- Page 99 and 100: You’ll get a result that is a bit
- Page 101 and 102: What if we want to place conditions
- Page 103 and 104: Let’s say, for example, that we w
- Page 105 and 106: Chapter 3: The Foundation Statement
- Page 107 and 108: City varchar(20) NOT NULL, State ch
- Page 109 and 110: for it in the INSERT statement. For
- Page 111 and 112: And sure enough, we get back the on
- Page 113 and 114: Chapter 3: The Foundation Statement
- Page 115 and 116: Chapter 3: The Foundation Statement
- Page 117: Chapter 3: The Foundation Statement
- Page 121 and 122: Now let’s see what happens when w
- Page 123 and 124: We can figure out which BusinessEnt
- Page 125 and 126: Be aware that using an alias is an
- Page 127 and 128: Person.Person Sales.Customer Busine
- Page 129 and 130: Notice that we did not use the INNE
- Page 131 and 132: Note that I’m deliberately elimin
- Page 133 and 134: know thus far? Actually, the very l
- Page 135 and 136: Note that whether you use a LEFT or
- Page 137 and 138: Just two records are returned: Vend
- Page 139 and 140: The question you should be asking n
- Page 141 and 142: How It Works As you can see, we hav
- Page 143 and 144: An Alternative INNER JOIN Let’s d
- Page 145 and 146: Dave’s Data 1212 Smith Ave Dave
- Page 147 and 148: JOIN Sales.Customer sc ON pp.Busine
- Page 149 and 150: Now, look at the heart of what’s
- Page 151 and 152: 5 Creating and Altering Tables Ever
- Page 153 and 154: ackward compatibility to prior vers
- Page 155 and 156: Reviewing the Defaults So let’s l
- Page 157 and 158: NAME This one isn’t quite what it
- Page 159 and 160: deprecates the older sp_attach_db f
- Page 161 and 162: The second provides specifics about
- Page 163 and 164: ❑ When building tables based on o
- Page 165 and 166: The NOT FOR REPLICATION parameter d
- Page 167 and 168: Let’s look at the specific syntax
- Page 169 and 170:
And then we moved on to a more spec
- Page 171 and 172:
❑ Date of hire ❑ Date terminate
- Page 173 and 174:
Note that I’ve chosen to use a da
- Page 175 and 176:
And . . . Name Fileid Filename File
- Page 177 and 178:
Name Fileid Filename Filegroup Acco
- Page 179 and 180:
} |{CHECK|NOCHECK} CONSTRAINT {ALL|
- Page 181 and 182:
Column_name Type Computed Length Pr
- Page 183 and 184:
Creating a Database Using the Manag
- Page 185 and 186:
Figure 5-3 Chapter 5: Creating and
- Page 187 and 188:
I’ve gone ahead and filled in the
- Page 189 and 190:
the pop-up menu, choose Script Data
- Page 191 and 192:
6 Constraints You’ve heard me tal
- Page 193 and 194:
Orders Table (Order ID Column) Figu
- Page 195 and 196:
that my users can’t sell a produc
- Page 197 and 198:
Do we want two customers to have th
- Page 199 and 200:
How It Works Once you have successf
- Page 201 and 202:
‘Head Cook & Bottle Washer’,
- Page 203 and 204:
Just remember that each constraint
- Page 205 and 206:
Chapter 6: Constraints So we have a
- Page 207 and 208:
Those Other CASCADE Actions … So,
- Page 209 and 210:
Once you establish a UNIQUE constra
- Page 211 and 212:
Chapter 6: Constraints The INSERT s
- Page 213 and 214:
Adding a DEFAULT Constraint to an E
- Page 215 and 216:
When we run this, we have a problem
- Page 217 and 218:
FedIDNo, DateInSystem) VALUES (‘M
- Page 219 and 220:
And it will show you your exact rul
- Page 221 and 222:
Determining Which Tables and Data T
- Page 223:
Summary Chapter 6: Constraints The
- Page 226 and 227:
Chapter 7: Adding More to Our Queri
- Page 228 and 229:
Chapter 7: Adding More to Our Queri
- Page 230 and 231:
Chapter 7: Adding More to Our Queri
- Page 232 and 233:
Chapter 7: Adding More to Our Queri
- Page 234 and 235:
Chapter 7: Adding More to Our Queri
- Page 236 and 237:
Chapter 7: Adding More to Our Queri
- Page 238 and 239:
Chapter 7: Adding More to Our Queri
- Page 240 and 241:
Chapter 7: Adding More to Our Queri
- Page 242 and 243:
Chapter 7: Adding More to Our Queri
- Page 244 and 245:
Chapter 7: Adding More to Our Queri
- Page 246 and 247:
Chapter 7: Adding More to Our Queri
- Page 248 and 249:
Chapter 7: Adding More to Our Queri
- Page 250 and 251:
Chapter 7: Adding More to Our Queri
- Page 252 and 253:
Chapter 7: Adding More to Our Queri
- Page 254 and 255:
Chapter 8: Being Normal: Normalizat
- Page 256 and 257:
Chapter 8: Being Normal: Normalizat
- Page 258 and 259:
Chapter 8: Being Normal: Normalizat
- Page 260 and 261:
Chapter 8: Being Normal: Normalizat
- Page 262 and 263:
Chapter 8: Being Normal: Normalizat
- Page 264 and 265:
Chapter 8: Being Normal: Normalizat
- Page 266 and 267:
Chapter 8: Being Normal: Normalizat
- Page 268 and 269:
Chapter 8: Being Normal: Normalizat
- Page 270 and 271:
Chapter 8: Being Normal: Normalizat
- Page 272 and 273:
Chapter 8: Being Normal: Normalizat
- Page 274 and 275:
Chapter 8: Being Normal: Normalizat
- Page 276 and 277:
Chapter 8: Being Normal: Normalizat
- Page 278 and 279:
Chapter 8: Being Normal: Normalizat
- Page 280 and 281:
Chapter 8: Being Normal: Normalizat
- Page 282 and 283:
Chapter 8: Being Normal: Normalizat
- Page 284 and 285:
Chapter 8: Being Normal: Normalizat
- Page 286 and 287:
Chapter 8: Being Normal: Normalizat
- Page 288 and 289:
Chapter 8: Being Normal: Normalizat
- Page 290 and 291:
Chapter 8: Being Normal: Normalizat
- Page 292 and 293:
Chapter 8: Being Normal: Normalizat
- Page 294 and 295:
Chapter 8: Being Normal: Normalizat
- Page 296 and 297:
Chapter 8: Being Normal: Normalizat
- Page 298 and 299:
Chapter 8: Being Normal: Normalizat
- Page 300 and 301:
Chapter 9: SQL Server Storage and I
- Page 302 and 303:
Chapter 9: SQL Server Storage and I
- Page 304 and 305:
Figure 9-1 Figure 9-2 1 53 104 Root
- Page 306 and 307:
Chapter 9: SQL Server Storage and I
- Page 308 and 309:
Chapter 9: SQL Server Storage and I
- Page 310 and 311:
Chapter 9: SQL Server Storage and I
- Page 312 and 313:
Chapter 9: SQL Server Storage and I
- Page 314 and 315:
Chapter 9: SQL Server Storage and I
- Page 316 and 317:
Chapter 9: SQL Server Storage and I
- Page 318 and 319:
Chapter 9: SQL Server Storage and I
- Page 320 and 321:
Chapter 9: SQL Server Storage and I
- Page 322 and 323:
Chapter 9: SQL Server Storage and I
- Page 324 and 325:
Chapter 9: SQL Server Storage and I
- Page 326 and 327:
Chapter 9: SQL Server Storage and I
- Page 328 and 329:
Chapter 9: SQL Server Storage and I
- Page 330 and 331:
Chapter 9: SQL Server Storage and I
- Page 332 and 333:
Chapter 9: SQL Server Storage and I
- Page 334 and 335:
Chapter 9: SQL Server Storage and I
- Page 337 and 338:
10 Views Up to this point, we’ve
- Page 339 and 340:
you are essentially saying to SQL S
- Page 341 and 342:
HireDate, TerminationDate, ManagerE
- Page 343 and 344:
Our result set has become a bit sma
- Page 345 and 346:
soh.OrderDate, sod.ProductID, pp.Na
- Page 347 and 348:
It’s surprising to many, but you
- Page 349 and 350:
Now try to update one of the rows u
- Page 351 and 352:
Figure 10-1 Before we close the Add
- Page 353 and 354:
Figure 10-4 When all is said and do
- Page 355 and 356:
FROM Sales.Customer AS sc INNER JOI
- Page 357 and 358:
About Schema Binding Schema binding
- Page 359 and 360:
Figure 10-5
- Page 361:
❑ Encrypt views when you don’t
- Page 364 and 365:
Chapter 11: Writing Scripts and Bat
- Page 366 and 367:
Chapter 11: Writing Scripts and Bat
- Page 368 and 369:
Chapter 11: Writing Scripts and Bat
- Page 370 and 371:
Chapter 11: Writing Scripts and Bat
- Page 372 and 373:
Chapter 11: Writing Scripts and Bat
- Page 374 and 375:
Chapter 11: Writing Scripts and Bat
- Page 376 and 377:
Chapter 11: Writing Scripts and Bat
- Page 378 and 379:
Chapter 11: Writing Scripts and Bat
- Page 380 and 381:
Chapter 11: Writing Scripts and Bat
- Page 382 and 383:
Chapter 11: Writing Scripts and Bat
- Page 384 and 385:
Chapter 11: Writing Scripts and Bat
- Page 386 and 387:
Chapter 11: Writing Scripts and Bat
- Page 388 and 389:
Chapter 11: Writing Scripts and Bat
- Page 390 and 391:
Chapter 11: Writing Scripts and Bat
- Page 392 and 393:
Chapter 11: Writing Scripts and Bat
- Page 394 and 395:
Chapter 11: Writing Scripts and Bat
- Page 396 and 397:
Chapter 11: Writing Scripts and Bat
- Page 398 and 399:
Chapter 11: Writing Scripts and Bat
- Page 400 and 401:
Chapter 11: Writing Scripts and Bat
- Page 402 and 403:
Chapter 11: Writing Scripts and Bat
- Page 405 and 406:
12 Stored Procedures Ah, the good s
- Page 407 and 408:
Now that we have our sproc created,
- Page 409 and 410:
The default is the first place we s
- Page 411 and 412:
If we were to run this with the sam
- Page 413 and 414:
ELSE -- hmm, we don’t recognize i
- Page 415 and 416:
CREATE PROC spTestReturns AS DECLAR
- Page 417 and 418:
Now, here things get a bit sticky a
- Page 419 and 420:
SELECT @Error = @@ERROR; -- Print o
- Page 421 and 422:
Our insert happens correctly, so no
- Page 423 and 424:
HireDate = @HireDate, CurrentFlag =
- Page 425 and 426:
Note the removal of the HireDate co
- Page 427 and 428:
Go ahead and run this once: DECLARE
- Page 429 and 430:
catastrophic (20-25). If you raise
- Page 431 and 432:
Let’s use this in a simple exampl
- Page 433 and 434:
As an example, let’s assume that
- Page 435 and 436:
Figure 12-1 Time of Creation At Exe
- Page 437 and 438:
If we create our sproc with this op
- Page 439 and 440:
You can test the arithmetic overflo
- Page 441 and 442:
❑ There are icons at the top (see
- Page 443 and 444:
The Call Stack Window The Call Stac
- Page 445 and 446:
line is different. This new green a
- Page 447:
Summary Wow! That’s a lot to have
- Page 450 and 451:
Chapter 13: User-Defined Functions
- Page 452 and 453:
Chapter 13: User-Defined Functions
- Page 454 and 455:
Chapter 13: User-Defined Functions
- Page 456 and 457:
Chapter 13: User-Defined Functions
- Page 458 and 459:
Chapter 13: User-Defined Functions
- Page 460 and 461:
Chapter 13: User-Defined Functions
- Page 462 and 463:
Chapter 13: User-Defined Functions
- Page 464 and 465:
Chapter 13: User-Defined Functions
- Page 466 and 467:
Chapter 14: Transactions and Locks
- Page 468 and 469:
Chapter 14: Transactions and Locks
- Page 470 and 471:
Chapter 14: Transactions and Locks
- Page 472 and 473:
Chapter 14: Transactions and Locks
- Page 474 and 475:
Chapter 14: Transactions and Locks
- Page 476 and 477:
Chapter 14: Transactions and Locks
- Page 478 and 479:
Chapter 14: Transactions and Locks
- Page 480 and 481:
Chapter 14: Transactions and Locks
- Page 482 and 483:
Chapter 14: Transactions and Locks
- Page 484 and 485:
Chapter 14: Transactions and Locks
- Page 486 and 487:
Chapter 14: Transactions and Locks
- Page 489 and 490:
15 Triggers Ah, triggers. Triggers
- Page 491 and 492:
ON While triggers take no parameter
- Page 493 and 494:
Statement issued: “INSERT INTO...
- Page 495 and 496:
SQL Server 6.5 and prior did not al
- Page 497 and 498:
Let’s go ahead and test out our h
- Page 499 and 500:
I just picked out “Adjustable Rac
- Page 501 and 502:
happen the second time around. Recu
- Page 503 and 504:
The syntax of sp_settriggerorder lo
- Page 505 and 506:
Another upshot of this part-of-the-
- Page 507 and 508:
5, and 7, then you need to add the
- Page 509 and 510:
that exercises the trigger we most
- Page 511 and 512:
16 A Brief XML Primer So, here we a
- Page 513 and 514:
So, this might have you asking the
- Page 515 and 516:
The declaration is made with a spec
- Page 517 and 518:
the scope of any particular XML doc
- Page 519 and 520:
As a side note, you can perform a r
- Page 521 and 522:
If we have more than one customer,
- Page 523 and 524:
The sql data type
- Page 525 and 526:
XML functionality was a relatively
- Page 527 and 528:
This is just a little confusing, so
- Page 529 and 530:
Chapter 16: A Brief XML Primer
- Page 531 and 532:
The result is rather verbose, so I
- Page 533 and 534:
If, for example, we wanted to incre
- Page 535 and 536:
7 30 1.00 7 45 0.50 7 50 3.00 7 60
- Page 537 and 538:
FOR XML provides three different in
- Page 539 and 540:
Easy, right? Well, now the boss com
- Page 541 and 542:
The downside to using AUTO is that
- Page 543 and 544:
While EXPLICIT has not been depreca
- Page 545 and 546:
Notice that our order count remaine
- Page 547 and 548:
FROM Sales.SalesOrderHeader Orders
- Page 549 and 550:
Next up are the mapping flags. Thes
- Page 551 and 552:
Imagine that you are merging with a
- Page 553 and 554:
What we have here is something XML
- Page 555 and 556:
17 Reporting for Duty , Sir! A Look
- Page 557 and 558:
Chapter 17: Reporting for Duty, Sir
- Page 559 and 560:
Chapter 17: Reporting for Duty, Sir
- Page 561 and 562:
Chapter 17: Reporting for Duty, Sir
- Page 563 and 564:
Chapter 17: Reporting for Duty, Sir
- Page 565 and 566:
Chapter 17: Reporting for Duty, Sir
- Page 567 and 568:
Chapter 17: Reporting for Duty, Sir
- Page 569 and 570:
Chapter 17: Reporting for Duty, Sir
- Page 571 and 572:
Chapter 17: Reporting for Duty, Sir
- Page 573 and 574:
Chapter 17: Reporting for Duty, Sir
- Page 575 and 576:
Chapter 17: Reporting for Duty, Sir
- Page 577 and 578:
Chapter 17: Reporting for Duty, Sir
- Page 579 and 580:
How It Works Chapter 17: Reporting
- Page 581 and 582:
18 Getting Integrated with Integrat
- Page 583 and 584:
Chapter 18: Getting Integrated with
- Page 585 and 586:
Chapter 18: Getting Integrated with
- Page 587 and 588:
Chapter 18: Getting Integrated with
- Page 589 and 590:
Examining Package Basics Fully exam
- Page 591 and 592:
Figure 18-12 Chapter 18: Getting In
- Page 593 and 594:
This brings up the OLE DB Source Ed
- Page 595 and 596:
Figure 18-17 Package Explorer This
- Page 597 and 598:
General Figure 18-19 Many fields on
- Page 599:
Executing the Package If you simply
- Page 602 and 603:
Chapter 19: Playing Administrator a
- Page 604 and 605:
Chapter 19: Playing Administrator Y
- Page 606 and 607:
Chapter 19: Playing Administrator 5
- Page 608 and 609:
Chapter 19: Playing Administrator 5
- Page 610 and 611:
Chapter 19: Playing Administrator 5
- Page 612 and 613:
Chapter 19: Playing Administrator 5
- Page 614 and 615:
Chapter 19: Playing Administrator A
- Page 616 and 617:
Chapter 19: Playing Administrator S
- Page 618 and 619:
Chapter 19: Playing Administrator R
- Page 620 and 621:
Chapter 19: Playing Administrator i
- Page 622 and 623:
Chapter 19: Playing Administrator P
- Page 625 and 626:
A System Functions SQL Server inclu
- Page 627 and 628:
@@IDLE Returns the time in millisec
- Page 629 and 630:
❑ CHECKSUM_AGG ❑ COUNT ❑ COUN
- Page 631 and 632:
GROUPING is only used in the SELECT
- Page 633 and 634:
❑ 4 — Thursday ❑ 5 — Friday
- Page 635 and 636:
If this evaluates to True, then you
- Page 637 and 638:
@@VERSION Returns the current versi
- Page 639 and 640:
DecryptByKey Like its asymmetric an
- Page 641 and 642:
SignByCert Returns a varbinary(8000
- Page 643 and 644:
If you are using the cursor variabl
- Page 645 and 646:
DAY The DAY function returns an int
- Page 647 and 648:
Yields: YEAR SELECT TODATETIMEOFFSE
- Page 649 and 650:
ABS ❑ LOG10 ❑ PI ❑ POWER ❑
- Page 651 and 652:
The expression must be of the float
- Page 653 and 654:
The expression must be of the float
- Page 655 and 656:
The id parameter specifies the ID o
- Page 657 and 658:
❑ ComparisonStyle — Indicates t
- Page 659 and 660:
❑ IsLogFile — The file is a log
- Page 661 and 662:
The return value from this function
- Page 663 and 664:
The return value from this function
- Page 665 and 666:
SQL_VARIANT_PROPERTY SQL_VARIANT_PR
- Page 667 and 668:
FREETEXTTABLE The FREETEXTTABLE fun
- Page 669 and 670:
IS_MEMBER The IS_MEMBER function re
- Page 671 and 672:
The user parameter is the username
- Page 673 and 674:
LEN The LEN function returns the nu
- Page 675 and 676:
SOUNDEX The SOUNDEX function return
- Page 677 and 678:
❑ NEWID ❑ NULLIF ❑ PARSENAME
- Page 679 and 680:
DATALENGTH The DATALENGTH function
- Page 681 and 682:
If you’re using identity columns
- Page 683 and 684:
SCOPE_IDENTITY The SCOPE_IDENTITY f
- Page 685 and 686:
The SERVERPROPERTY function is very
- Page 687 and 688:
B Very Simple Connectivity Examples
- Page 689 and 690:
Connecting in C# C# is a fairly cle
- Page 691 and 692:
} } Console.ReadLine(); // Change t
- Page 693 and 694:
Dim strCommand2 As String = “DROP
- Page 695 and 696:
SYMBOLS - (minus sign) for placehol
- Page 697 and 698:
B backup (databases) Back Up Databa
- Page 699 and 700:
constraints, 154-186 CHECK constrai
- Page 701 and 702:
database administration and mainten
- Page 703 and 704:
E editing properties and objects, 2
- Page 705 and 706:
fragmenting of indexes, 580 FREETEX
- Page 707 and 708:
ISDATE function, 607 IsDescendantOf
- Page 709 and 710:
NONCLUSTERED k eyword, 285 non-dete
- Page 711 and 712:
parentheses ( ) subqueries and, 188
- Page 713 and 714:
eport models, building. See report
- Page 715 and 716:
sp_help command, 131 sp_helpdb util
- Page 717 and 718:
adding foreign keys to, 162 adding
- Page 719 and 720:
U UDFs. See user-defined functions