Slash-Asterisk Style Comments

The /* style comment is a Transact-SQL extension. Multiple-line comments are acceptable, as long as each comment starts with “/*” and ends with “*/”. Everything between “/*” and “*/” is treated as part of the comment. The /* form permits nesting.

A stylistic convention often used for multiple-line comments is to begin the first line with “/*” and subsequent lines with “**”. End such a comment with “*/” as usual:

select * from titles 
/* A comment here might explain the rules 
** associated with using an asterisk as 
** shorthand in the select list.*/ 
where price > $5 

This procedure includes several comments:

/* this procedure finds rules by user name*/ 
create procedure findmyrule @nm varchar(30) = null 
if @nm is null 
  print "You must give a user name" 
  print "I have returned" 
/* this statement follows return, 
** so won’t be executed */ 
else      /* print the rule names and IDs, and 
          the user ID */ 
  from sysobjects, master..syslogins 
  where = @nm 
  and sysobjects.uid = master..syslogins.suid 
  and sysobjects.type = "R"