Indicates user-provided text. The text between the /* and */ commenting characters is not evaluated by the server.
/ * text_of_comment * /
text_of_comment
Is the character string(s) containing the text of the comment.
Comments can be inserted on a separate line or within a Transact-SQL statement. Multiple-line comments must be indicated by /* and */. A stylistic convention often used for multiple-line comments is to begin the first line with /*, subsequent lines with **, and end with */.
There is no maximum length for comments.
Note Including a GO command within a comment generates an error message.
This example uses comments to document and test the behavior during different phases of development for a trigger. In this example, parts of the trigger are commented out to narrow down problems and test only one of the conditions. Both styles of comments are used; SQL-92 style (--) comments are shown both alone and nested.
Note The following CREATE TRIGGER statement fails because a trigger named employee_insupd already exists in the pubs database.
CREATE TRIGGER employee_insupd/*Because CHECK constraints can only reference the column(s)on which the column- or table-level constraint hasbeen defined, any cross-table constraints (in this case,business rules) need to be defined as triggers.Employee job_lvls (on which salaries are based) should be withinthe range defined for their job. To get the appropriate range,the jobs table needs to be referenced. This trigger will beinvoked for INSERT and UPDATES only.*/ON employeeFOR INSERT, UPDATEAS/* Get the range of level for this job type from the jobs table. */DECLARE @min_lvl tinyint,-- Minimum level var. declaration@max_lvl tinyint,-- Maximum level var. declaration@emp_lvl tinyint,-- Employee level var. declaration@job_id smallint-- Job ID var. declarationSELECT @min_lvl = min_lvl,-- Set the minimum level@max_lvl = max_lvl,-- Set the maximum level@emp_lvl = i.job_lvl,-- Set the proposed employee level@job_id = i.job_id-- Set the Job ID for comparisonFROM employee e, jobs j, inserted iWHERE e.emp_id = i.emp_id AND i.job_id = j.job_idIF (@job_id = 1) and (@emp_lvl <> 10)BEGINRAISERROR ('Job id 1 expects the default level of 10.', 16, 1)ROLLBACK TRANSACTIONEND/* Only want to test first condition. Remaining ELSE is commented out.-- Comments within this section are unaffected by this commenting style.ELSEIF NOT (@emp_lvl BETWEEN @min_lvl AND @max_lvl) -- Check valid rangeBEGINRAISERROR ('The level for job_id:%d should be between %d and %d.',16, 1, @job_id, @min_lvl, @max_lvl)ROLLBACK TRANSACTIONEND*/GO