MS SQL Basics Tutorial: SQL other commands

Source: Internet
Author: User
Tags backup

4.7.1 BACKUP

The backup command is used to back up database content or its transaction log to storage media (floppy disk, hard disk, tape). The dump command is used to perform this function when the previous version of SQL Server 7.0 is in use, and the dump command is no longer used from SQL Server 2000. For more information on the backup command, see the "Data Backup and Recovery" section.

4.7.2 CHECKPOINT

The syntax is as follows:

CHECKPOINT

The CHECKPOINT command is used to force a data page, or log page, that has been changed in the current working database, from being forced to the hard drive from the data buffer cache.

4.7.3 DBCC

DBCC Database Base Consistency Checker, Database consistency checker) commands are used to validate the integrity of databases, find errors, analyze system usage, and so on.

The DBCC command must be followed by a child command, and the system knows what to do. The DBCC CHECKALLOC command checks the allocation and usage of all data pages in the current database.

For more information on the DBCC command, see Appendix.

4.7.4 DECLARE

The syntax is as follows:

DECLARE {{@local_variable data_type}

| {@cursor_variable_name cursor}

| {table_type_definition}

} [, .... N]]

The DECLARE command declares one or more local variables, cursor variables, or table variables. After the declare command is declared, all variables are given an initial value of NULL. You need to assign a value to a variable with a select or SET command. Variable types can be system-defined or user-defined types, but not text, NTEXT, or image types. The CURSOR named variable is a local cursor variable.

Example 4-16

DECLARE @x float @y datetime

Select @x = Pi @y = getdate

Print @x

Print @y

The results of the operation are as follows:

3.14159

June 4:32pm

Note: If the variable is a character type, then the data_type expression should indicate

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.