Sqlsever comment and Multiline comment _mssql

Source: Internet
Author: User

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-not added Student. The column name ' Sno ' is ambiguous. Having 
MIN (grade) >= 60 

Multi-line Comment:

 
/* Grant all permissions to the Student table and Course table to the user U2 and U3  
 Grant all priviliges www.jb51.net on   
        table Student, Course  
           to U2, U3;  
Grant the query permissions on the table SC to all users  
grant SELECT on table SC to public  
; 
Grant the user U4 GRANT UPDATE (Sno) the Query Student table and the permission to modify the student number  
, SELECT on  
           table Student to U4;  
 REVOKE UPDATE (Sno) on the TABLE Student from U4 the user U4 modify the student number's permission; 

Effect Chart:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.