Provide a Pronunciation Key when appropriate


I highly recommend the use of a pronunciation key so there is NO QUESTION about how to pronounce the elements in your script. I did a project for a large software company where nothing was left to question. Although the script is highly technical, it was a (relative) breeze to complete because of the pronunciation key shown before the script. Imagine trying this without the pronunciation key!

Pronunciation Key:

Microsoft SQL Server Desktop: Microsoft seequel Server Desktop
Transact-SQL: Transact-es-qu-el
SQL Server 2000: Sequel-server-two-thousand
@@ERROR: at-at-error
Transact-SQL: transact-S-Q-L
Microsoft SQL Server: Microsoft sequel Server
TRY.CATCH: try-catch
0: zero
ERROR_LINE: error-underscore-line
ERROR_MESSAGE: error-underscore-message
ERROR_PROCEDURE: error-underscore-procedure
ERROR_SEVERITY: error-underscore-severity
ERROR_STATE: error-underscore-state
END CATCH: end-catch
BEGIN TRY: begin-try
END TRY: end-try


Script:

SQL Server 2000 uses the @@ERROR function to detect errors in Transact-SQL statements. Microsoft SQL Server Desktop Engine uses the TRY.CATCH construct.

The @@ERROR function returns the error number of an error that has been encountered, whereas the TRY.CATCH construct provides more information about the error.

If the code runs successfully, the @@ERROR function returns 0. If the @@ERROR function returns a value other than 0, the program control is passed on to the error handler code.

In the case of the TRY.CATCH construct, the code that can raise an error is inserted in the TRY block. If the TRY block detects an error, the control of the program is transferred to the CATCH block. Inside a CATCH block, you can use functions, such as ERROR_LINE, ERROR_MESSAGE, ERROR_PROCEDURE, ERROR_SEVERITY, and ERROR_STATE to obtain information about an exception. Otherwise, the control is transferred to the next statement after the END CATCH statement.

@@ERRORs must be either tested or saved after every Transact-SQL statement because a developer cannot predict which statement might generate an error. This doubles the number of Transact-SQL statements that must be used to implement a given piece of logic.

TRY.CATCH constructs are much simpler. A block of Transact-SQL statements is bound by BEGIN TRY and END TRY statements, and then one CATCH block is written to handle errors that might be generated by that block of statements.


HOME