Beginning Microsoft SQL Server 2008 ... - S3 Tech Training
Beginning Microsoft SQL Server 2008 ... - S3 Tech Training Beginning Microsoft SQL Server 2008 ... - S3 Tech Training
Appendix A: System Functions SUM The SUM function will return the total of all values in expression. The syntax is as follows: SUM([ALL | DISTINCT] ) SUM ignores NULL values. This function supports the OVER operator described in the ranking functions section of this appendix. VAR The VAR function returns the variance of all values in expression. The syntax is as follows: VAR() VAR ignores NULL values. This function supports the OVER operator described in the ranking functions section of this appendix. VARP The VARP function returns the variance for the population of all values in expression. The syntax is as follows: VARP() VARP ignores NULL values. This function supports the OVER operator described in the ranking functions section of this appendix. Configuration Functions Well, I’m sure it will come as a complete surprise (ok, not really…), but configuration functions are those functions that tell us about options as they are set for the current server or database (as appropriate). @@DATEFIRST 594 Returns the numeric value that corresponds to the day of the week that the system considers the first day of the week. The default in the United States is 7, which equates to Sunday. The values convert as follows: ❑ 1 — Monday (the first day for most of the world) ❑ 2 — Tuesday ❑ 3 — Wednesday
❑ 4 — Thursday ❑ 5 — Friday ❑ 6 — Saturday ❑ 7 — Sunday This can be really handy when dealing with localization issues, so you can properly layout any calendar or other day-of-week-dependent information you have. Use the SET DATEFIRST function to alter this setting. @@DBTS Returns the last used timestamp for the current database. At first look, this one seems to act an awful lot like @@IDENTITY in that it gives you the chance to get back the last value set by the system (this time, it’s the last timestamp instead of the last identity value). The things to watch out for on this one include: ❑ The value changes based on any change in the database, not just the table you’re working on. ❑ Any timestamp change in the database is reflected, not just those for the current connection. Because you can’t count on this value truly being the last one that you used (someone else may have done something that would change it), I personally find very little practical use for this one. @@LANGID and @@LANGUAGE Respectively return the ID and the name of the language currently in use. These can be handy for figuring out if your product has been installed in a localization situation or not, and if so, what language is the default. For a full listing of the languages currently supported by SQL Server, use the system stored procedure, sp_helplanguage. @@LOCK_TIMEOUT Apendix A: System Functions Returns the current amount of time in milliseconds before the system will time out waiting for a blocked resource. If a resource (a page, a row, a table, whatever) is blocked, your process will stop and wait for the block to clear. This determines just how long your process will wait before the statement is canceled. 595
- Page 582 and 583: Chapter 18: Getting Integrated with
- Page 584 and 585: Chapter 18: Getting Integrated with
- Page 586 and 587: Chapter 18: Getting Integrated with
- Page 588 and 589: Chapter 18: Getting Integrated with
- Page 590 and 591: Chapter 18: Getting Integrated with
- Page 592 and 593: Chapter 18: Getting Integrated with
- Page 594 and 595: Chapter 18: Getting Integrated with
- Page 596 and 597: Chapter 18: Getting Integrated with
- Page 598 and 599: Chapter 18: Getting Integrated with
- Page 601 and 602: 19 Playing Administrator And so, he
- Page 603 and 604: ❑ Write the information to the ev
- Page 605 and 606: Creating Jobs and Tasks Using Manag
- Page 607 and 608: Let’s go ahead and move on to the
- Page 609 and 610: Figure 19-8 Figure 19-9 Chapter 19:
- Page 611 and 612: Figure 19-11 Figure 19-12 Chapter 1
- Page 613 and 614: Backup and Reco very No database-dr
- Page 615 and 616: ❑ Differential: This might be ref
- Page 617 and 618: ❑ Simple: Under this model, the t
- Page 619 and 620: The older DBCC commands are still s
- Page 621 and 622: many rows inserted over time and th
- Page 623: Chapter 19: Playing Administrator T
- Page 626 and 627: Appendix A: System Functions In add
- Page 628 and 629: Appendix A: System Functions @@TOTA
- Page 630 and 631: Appendix A: System Functions CHECKS
- Page 634 and 635: Appendix A: System Functions The de
- Page 636 and 637: Appendix A: System Functions @@REMS
- Page 638 and 639: Appendix A: System Functions Cert_I
- Page 640 and 641: Appendix A: System Functions Encryp
- Page 642 and 643: Appendix A: System Functions @@FETC
- Page 644 and 645: Appendix A: System Functions CURREN
- Page 646 and 647: Appendix A: System Functions SYSDAT
- Page 648 and 649: Appendix A: System Functions GetRoo
- Page 650 and 651: Appendix A: System Functions The ex
- Page 652 and 653: Appendix A: System Functions RAND T
- Page 654 and 655: Appendix A: System Functions ❑ IN
- Page 656 and 657: Appendix A: System Functions ❑ Is
- Page 658 and 659: Appendix A: System Functions FILEGR
- Page 660 and 661: Appendix A: System Functions INDEX_
- Page 662 and 663: IsCheckCnst IsConstraint IsDefault
- Page 664 and 665: Appendix A: System Functions OBJECT
- Page 666 and 667: Appendix A: System Functions TYPEPR
- Page 668 and 669: Appendix A: System Functions The qu
- Page 670 and 671: Appendix A: System Functions The SU
- Page 672 and 673: Appendix A: System Functions ASCII
- Page 674 and 675: Appendix A: System Functions The ch
- Page 676 and 677: Appendix A: System Functions UNICOD
- Page 678 and 679: Appendix A: System Functions CAST a
- Page 680 and 681: Appendix A: System Functions HOST_I
❑ 4 — Thursday<br />
❑ 5 — Friday<br />
❑ 6 — Saturday<br />
❑ 7 — Sunday<br />
This can be really handy when dealing with localization issues, so you can properly layout any calendar<br />
or other day-of-week-dependent information you have.<br />
Use the SET DATEFIRST function to alter this setting.<br />
@@DBTS<br />
Returns the last used timestamp for the current database.<br />
At first look, this one seems to act an awful lot like @@IDENTITY in that it gives you the chance to get<br />
back the last value set by the system (this time, it’s the last timestamp instead of the last identity value).<br />
The things to watch out for on this one include:<br />
❑ The value changes based on any change in the database, not just the table you’re working on.<br />
❑ Any timestamp change in the database is reflected, not just those for the current connection.<br />
Because you can’t count on this value truly being the last one that you used (someone else may have<br />
done something that would change it), I personally find very little practical use for this one.<br />
@@LANGID and @@LANGUAGE<br />
Respectively return the ID and the name of the language currently in use.<br />
These can be handy for figuring out if your product has been installed in a localization situation or not,<br />
and if so, what language is the default.<br />
For a full listing of the languages currently supported by <strong>SQL</strong> <strong>Server</strong>, use the system stored procedure,<br />
sp_helplanguage.<br />
@@LOCK_TIMEOUT<br />
Apendix A: System Functions<br />
Returns the current amount of time in milliseconds before the system will time out waiting for a blocked<br />
resource.<br />
If a resource (a page, a row, a table, whatever) is blocked, your process will stop and wait for the block to<br />
clear. This determines just how long your process will wait before the statement is canceled.<br />
595