Current location - Recipe Complete Network - Food world - What does sqlgo mean and how to use it?
What does sqlgo mean and how to use it?

The usage of go, begin and end in SQL is as follows:

go signals the SQL Server utility to end a batch of Transact-SQL statements. Go executes the t-sql statements in batches (if this step is successful, the next step is executed, that is, one step at a time).

BEGIN and END statements are used to combine multiple Transact-SQL statements into a logical block. The BEGIN and END statements can be used to control the situation where a flow statement must execute blocks of two or more Transact-SQL statements.

the p>BEGIN and END statements must be used in pairs: they cannot be used separately. The BEGIN statement is displayed on one line, followed by the Transact-SQL statement block. Finally, the END statement is displayed on a separate line, indicating the end of the statement block.

ExtENDed data:

For example, when the IF statement only controls the execution of a Transact-SQL statement, there is no need to use the BEGIN or end statement:

if (@ @ error <; > 1)

SET @ errorsavevariable = @@ ERROR

If @ @ error is 1, only the set statement will be skipped.

when the calculation result is FALSE, use the BEGIN and END statements to make the IF statement skip the statement block:

if (@ @ error <; > 1)

BEGIN

SET @ErrorSaveVariable = @@ERROR

PRINT 'Error encountered, ' +

CAST(@ErrorSaveVariable AS VARCHAR(11))

END