Environment: SQL Server 2008 R2
Question: The annotation usage in SQL Server is not clear.
Solve:
Single-line Comment:--
Multi-line Comment:/*......*/
Use examples:
single-line Comment:
-The column ' Student.sname ' in the select list is not valid because the column is not included in an aggregate function or a GROUP by clause.
SELECT Student.sno,sname,avg (grade) as Avg_g
From STUDENT,SC www.jb51.net
WHERE Student.sno=sc.sno and cno<> ' 008 '
GROUP by Student.sno-No add Student. The column name ' Sno ' is ambiguous.
Having MIN (grade) >= 60
Order by Avg_g DESC;
Multi-line Comment:
/*
Grant the user U2 and U3 all the permissions on the student table and the course table
GRANT All priviliges www.jb51.net
On TABLE Student, Course
to U2, U3;
Grant query permissions to table SC to all users
GRANT SELECT on TABLE SC
to public;
Grant the user the right to inquire student the table and modify the student number U4
GRANT UPDATE (Sno), SELECT
On TABLE Student to U4;
The user U4 to revise the student number's permission to withdraw
REVOKE UPDATE (Sno) on the TABLE Student from U4;
*/
Effect Chart: