Comments are used to attach explanatory text to SQL statements or statement blocks. Comments are not executed by the database engine.
Several comment indicators are available in SQL Anywhere.
-- (Double hyphen.) Any remaining characters on the line are ignored by the database engine. This is the SQL/92 comment indicator.
% (Percent sign.) The percent sign has the same meaning as the double hyphen.
// (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 may be on the same or different lines. Comments indicated in this style can be nested.
Transact-SQL compatibility The double-hyphen and the slash-asterisk comment styles are compatible with Transact-SQL. |
The following examples illustrate the use of 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
/*
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 "dba".employee
WHERE dept_id = 200