Introduction to basic functional statements for SQL Server _mssql

Source: Internet
Author: User

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}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.