nerdexam
EC-Council

312-50V11 · Question #342

Which of the following is used to indicate a single-line comment in structured query language (SQL)?

The correct answer is A. --. In SQL, the double hyphen (--) is the ANSI-standard delimiter for a single-line comment, causing the parser to ignore all text following it on the same line.

SQL Injection

Question

Which of the following is used to indicate a single-line comment in structured query language (SQL)?

Options

  • A--
  • B||
  • C%%
  • D''

How the community answered

(29 responses)
  • A
    86% (25)
  • B
    3% (1)
  • C
    3% (1)
  • D
    7% (2)

Why each option

In SQL, the double hyphen (--) is the ANSI-standard delimiter for a single-line comment, causing the parser to ignore all text following it on the same line.

A--Correct

The double hyphen (--) is defined by the ANSI SQL standard as the single-line comment syntax; every character after -- on that line is ignored by the SQL engine at parse time. This syntax is also commonly exploited in SQL injection attacks to truncate and neutralize the remainder of a query.

B||

The double pipe (||) is the SQL string concatenation operator used to join two string expressions and has no role as a comment delimiter.

C%%

The percent sign (%) serves as a wildcard in SQL LIKE predicates; double percent (%%) has no defined meaning as a comment syntax in standard SQL.

D''

Two consecutive single quotes ('') represent an escaped single-quote character or an empty string literal in SQL and are not treated as a comment delimiter.

Concept tested: SQL single-line comment syntax

Source: https://learn.microsoft.com/en-us/sql/t-sql/language-elements/comment-transact-sql

Topics

#SQL comments#SQL syntax#comment injection

Community Discussion

No community discussion yet for this question.

Full 312-50V11 Practice