SQL Comments

A-Z of Mircrosoft SQL

Main Page Introduction SSMS Acronym's used in SQL SQL Commands SQL Functions SQL Store Procedures SQL Views SQL Triggers SQL Operators SQL - Adding Comments SQL Alias SQL Joins SQL - Building Basic Scripts SQL - Execution Plan Questions or Suggestions
H1B Jobs- Visual Reports

SQL Examples

Arithmetic Operators Comparision Operators Logical Operators Bitwise Operators String Functions Date Functions Numeric Functions


SQL Comments

When you write your SQL scripts , many times it runs into hundered of lines and it is very important to write some comments so we can refer to them later.

Also you can write a part of code and comment it out so we can use if for future , or it wont be used anymore.

They are baiscally two types- examples on how we can use comments are given below

Single Line Comments

We can add single line comments by entering '--' at the begining of a certain line.

Commenting out a single line in SQL

We can use this to comment out any SQL as well, this we when we run the script - results are not generated for that part.

Commenting out a MULTIPLE lines using a single line comment in SQL

In case we need to comment out multiple line, this method may be cumborsome , this leads us to the next type below.

Multiple Line Comments

We can comment out multiple Lines of a code , or write information in multiple lines by using '/*' at the begining and '*/' at the end

Below we comment out all three lines using the method.

Commenting out multiple lines of code in SQL

Next Stop: SQL Alias