Use comments to attach explanatory text to SQL statements or statement blocks. The database server does not execute comments.
Several comment indicators are available in Sybase IQ:
-- (Double hyphen) The database server ignores any remaining characters on the line. This is the SQL92 comment indicator.
// (Double slash) The double slash has the same meaning as the double hyphen.
/* … */ (Slash-asterisk) Any characters between the two comment markers are ignored. The two comment markers might be on the same or different lines. Comments indicated in this style can be nested. This style of commenting is also called C-style comments.
% (Percent sign) The percent sign has the same meaning as the double hyphen. Sybase recommends that you do not use % as a comment indicator.
The double-hyphen and the slash-asterisk comment styles are compatible with Adaptive Server Enterprise.
This example illustrates the use of double-dash comments:
CREATE FUNCTION fullname (firstname CHAR(30), lastname CHAR(30)) RETURNS CHAR(61) -- fullname concatenates the firstname and lastname -- arguments with a single space between. BEGIN DECLARE name CHAR(61); SET name = firstname || ' ' || lastname; RETURN ( name ); END
This example illustrates the use of C-style comments:
/* Lists the names and employee IDs of employees who work in the sales department. */ CREATE VIEW SalesEmployee AS SELECT emp_id, emp_lname, emp_fname FROM "GROUPO".Employees WHERE DepartmentID = 200