Introduction to basic functional statements of SQL Server

Source: Internet
Author: User

1 annotator
Annotation is a text string that is not executed in the program code. It is a description of the program, which can improve the readability of the program and make the program code easier to maintain, it is usually embedded in a program and displayed with special marks. In Transact-SQL, annotations can be included in batch processing, stored procedures, and triggers. There are two types of annotators:
--: This is an ANSI-standard annotator consisting of two consecutive characters for single line comments.
/*... */: This is the same program annotator as the C language./* is used to start the comment text. */is used to end the comment text. multiple lines of text can be identified as the comment statement in the program.

2. PRINT)
The PRINT statement of the output statement is used to transmit a message to a client application. It is usually displayed on the user screen. The message string can contain up to 8000 characters, and any character exceeding 8000 characters is truncated. The PRINT statement can only transmit text strings or a single character variable. The PRINT statement can also pass global variables, but can only be a global variable of the character type.
PRINT statement Syntax:
PRINT 'text' | @ local variable | @ global variable | string expression
Although the PRINT statement can only display strings, many functions are provided in Transact-SQL to convert other data types into strings.

3. RAISERROR)
The RAISERROR command is used to return 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 send the text of the error number, severity, error status, and error message to the customer's application.
Compared with PRINT, RAISERROR is more powerful in returning messages to applications. Therefore, if you need to call SQL Server 2005 database system errors in a program, you need to use the RAISERROR command.

4. SET)
In SQL Server 2005, some options are set in the database system to affect the way the Server processes specific conditions. These options exist in the user's connection to the Server or the user's stored procedures and triggers, you can use the SET statement to SET these parameters. Syntax:
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.