SQL Process Control Statements

Source: Internet
Author: User
Tags getdate goto

1 goto statement

IF 12>9
GOTO Print1
ELSE
GOTO Print2

Print1:print ' performed the process 1 '
--goto theend
Print2:print ' performed the process 2 '
GOTO theend
Print3:print ' performed the process 3 '

Theend:print ' Process end ';

2 case and then ELSE End statement

SELECT CONVERT (NVARCHAR, GETDATE (), 121) Date, Case MONTH (GETDATE ()) when ' one ' then ' 11 ' if ' Then ' 12 '
ELSE SUBSTRING (' 1,234,567,890 ', Month (GETDATE ()), 1) + ' month ' END month

3 WAITFOR Statements

--==========================================================================
--1, WAITFOR statement
--The DESC:WAITFOR statement is used to defer subsequent code execution, or wait until a specified time to execute subsequent code
--==========================================================================

Additional examples:
There are two uses:
1, delay after a period of time to execute
Like what:
WAITFOR DELAY ' 00:00:05 '
print ' delay 5 seconds to execute! ‘
--Execute print after 5 seconds
2. When the designation is executed
Like what:
waitfor time ' 21:17 '
print ' 21:17 execution '

SQL Process Control Statements

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.