1 annotation Characters
Note refers to the program code does not execute the text string, is a description of the program, you can improve the readability of the program, so that the program code easier to maintain, generally embedded in the program and with special tags displayed. In Transact-SQL, annotations can be included in batches, stored procedures, triggers, and there are two types of annotation characters:
--This is a two-hyphen annotation of the ANSI standard for single-line comments.
/*...*/: This is the same as the C language of the program annotation,/* For the beginning of the annotation text, */For the end of the comment text, you can identify multiple lines of text in the program as an annotation statement.
2 Output statement (print)
The OUTPUT statement print statement is used to pass messages to the client application, usually on the user's screen, with a message string up to 8,000 characters long and any character of more than 8,000 truncated. The print statement can only transfer text-type strings, or a single character variable, and the print statement may pass global variables, but only the global variables of character types.
The print statement syntax is as follows:
PRINT ' Text ' | @ Local Variables | @@ 全局 Variable | string expression
Although the print statement can only display strings, many functions are provided in Transact-SQL to convert other data types to strings.
3 Error Handling statement (RAISERROR)
The RAISERROR command returns the user-specified information when the SQL Server 2005 system returns an error message. The RAISERROR command can automatically record the error number specified in the global variable @ @error and transfer the error number, severity, error status, and text of the error message to the customer's application.
RAISERROR is more powerful at returning messages to applications than print, so if a user needs to call a SQL Server 2005 database system error in a program, the RAISERROR command is required.
The
4 Option Setup statement (set)
SQL Server 2005 database system sets options that affect how the server handles specific conditions. These options exist in the user's connection to the server or in the user's stored procedures and triggers, and can be set using the SET statement. The syntax is as follows:
SET condition {on | off | Value}