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 HOST_ID The HOST_ID function returns the ID of the workstation. The syntax is as follows: HOST_ID() HOST_NAME The HOST_NAME function returns the name of the workstation. The syntax is as follows: HOST_NAME() IDENT_CURRENT The IDENT_CURRENT function returns the last identity value created for a table, within any session or scope of that table. This is exactly like @@IDENTITY and SCOPE_IDENTITY; however, this has no limit to the scope of its search to return the value. The syntax is as follows: IDENT_CURRENT(‘’) The table_name is the table for which you wish to find the current identity. IDENT_INCR The IDENT_INCR function returns the increment value specified during the creation of an identity column in a table or view that has an identity column. The syntax is as follows: IDENT_INCR(‘’) The table_or_view parameter is an expression specifying the table or view to check for a valid identity increment value. IDENT_SEED The IDENT_SEED function returns the seed value specified during the creation of an identity column in a table or a view that has an identity column. The syntax is as follows: IDENT_SEED(‘’) The table_or_view parameter is an expression specifying the table or view to check for a valid identity increment value. @@IDENTITY 642 Returns the last identity value created by the current connection.
If you’re using identity columns and then referencing them as a foreign key in another table, you’ll find yourself using this one all the time. You can create the parent record (usually the one with the identity you need to retrieve), then select @@IDENTITY to know what value you need to relate child records to. If you perform inserts into multiple tables with identity values, remember that the value in @@IDENTITY will only be for the last identity value inserted — anything before that will have been lost, unless you move the value into a holding variable after each insert. Also, if the last column you inserted into didn’t have an identity column, then @@IDENTITY will be set to NULL. IDENTITY The IDENTITY function is used to insert an identity column into a new table. It is used only with a SELECT statement with an INTO table clause. The syntax is as follows: Where: ISNULL IDENTITY([, , ]) AS ❑ data type is the data type of the identity column. ❑ seed is the value to be assigned to the first row in the table. Each subsequent row is assigned the next identity value, which is equal to the last IDENTITY value plus the increment value. If neither seed nor increment is specified, both default to 1. ❑ increment is the increment to add to the seed value for successive rows in the table. ❑ column name is the name of the column that is to be inserted into the new table. The ISNULL function checks an expression for a NULL value and replaces it with a specified replacement value. The syntax is as follows: ISNULL(, ) ISNUMERIC The ISNUMERIC function determines whether an expression is a valid numeric type. The syntax is as follows: NEWID ISNUMERIC() The NEWID function creates a unique value of type uniqueidentifier. The syntax is as follows: NEWID() Apendix A: System Functions 643
- Page 630 and 631: Appendix A: System Functions CHECKS
- Page 632 and 633: Appendix A: System Functions SUM Th
- 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 682 and 683: Appendix A: System Functions NULLIF
- Page 684 and 685: Appendix A: System Functions 646 Pr
- Page 686 and 687: Appendix A: System Functions Text a
- Page 688 and 689: Appendix B: Very Simple Connectivit
- Page 690 and 691: Appendix B: Very Simple Connectivit
- Page 692 and 693: Appendix B: Very Simple Connectivit
- Page 694 and 695: Appendix B: Very Simple Connectivit
- Page 696 and 697: ABS function A ABS function, 611 AC
- Page 698 and 699: closing tags closing tags, XML docu
- Page 700 and 701: cryptographic functions (continued)
- Page 702 and 703: defects defects. See well formed XM
- Page 704 and 705: EXPLICIT option EXPLICIT option bas
- Page 706 and 707: IGNORE_DUP_KEY option (CREATE INDEX
- Page 708 and 709: LOWER function LOWER function, 635
- Page 710 and 711: online transaction-processing (OLTP
- Page 712 and 713: query results query results alphabe
- Page 714 and 715: scripts (continued) creating with M
- Page 716 and 717: state state, basics of, 391 stateme
- Page 718 and 719: transactions (continued) COMMIT TRA
- Page 720: View Builder View Builder (Manageme
Appendix A: System Functions<br />
HOST_ID<br />
The HOST_ID function returns the ID of the workstation. The syntax is as follows:<br />
HOST_ID()<br />
HOST_NAME<br />
The HOST_NAME function returns the name of the workstation. The syntax is as follows:<br />
HOST_NAME()<br />
IDENT_CURRENT<br />
The IDENT_CURRENT function returns the last identity value created for a table, within any session or<br />
scope of that table. This is exactly like @@IDENTITY and SCOPE_IDENTITY; however, this has no limit to<br />
the scope of its search to return the value.<br />
The syntax is as follows:<br />
IDENT_CURRENT(‘’)<br />
The table_name is the table for which you wish to find the current identity.<br />
IDENT_INCR<br />
The IDENT_INCR function returns the increment value specified during the creation of an identity column<br />
in a table or view that has an identity column. The syntax is as follows:<br />
IDENT_INCR(‘’)<br />
The table_or_view parameter is an expression specifying the table or view to check for a valid identity<br />
increment value.<br />
IDENT_SEED<br />
The IDENT_SEED function returns the seed value specified during the creation of an identity column in a<br />
table or a view that has an identity column. The syntax is as follows:<br />
IDENT_SEED(‘’)<br />
The table_or_view parameter is an expression specifying the table or view to check for a valid identity<br />
increment value.<br />
@@IDENTITY<br />
642<br />
Returns the last identity value created by the current connection.