nerdexam
Snowflake

SOL-C01 · Question #27

Consider the following SQL code snippet intended to insert data into a Snowflake table named 'employees'. However, the execution results in a data type mismatch error. Analyze the code and identify th

The correct answer is C. The string 'Five Thousand' cannot be implicitly converted to a NUMBER(10,2) for the 'salary'. Option C is correct because SQL databases, including Snowflake, require that values inserted into a column match (or be implicitly convertible to) the column's defined data type. The string literal 'Five Thousand' is textual data that Snowflake cannot automatically convert to NUM

Data Loading and Unloading

Question

Consider the following SQL code snippet intended to insert data into a Snowflake table named 'employees'. However, the execution results in a data type mismatch error. Analyze the code and identify the root cause of the error. Assume the 'salary' column in the 'employees' table is defined as NUMBER(10,2).

Options

  • AThe 'insert' statement is missing the column names explicitly.
  • BThe date format 'YYYY-MM-DD' is incorrect for the 'hire date' column.
  • CThe string 'Five Thousand' cannot be implicitly converted to a NUMBER(10,2) for the 'salary'
  • DThe 'dept_id' is not a valid integer value.
  • EThe semi-colon (;) at the end of the VALUES clause is causing a syntax error.

How the community answered

(42 responses)
  • A
    5% (2)
  • B
    17% (7)
  • C
    67% (28)
  • D
    2% (1)
  • E
    10% (4)

Explanation

Option C is correct because SQL databases, including Snowflake, require that values inserted into a column match (or be implicitly convertible to) the column's defined data type. The string literal 'Five Thousand' is textual data that Snowflake cannot automatically convert to NUMBER(10,2) - the numeric value 5000.00 must be provided instead.

Why the distractors are wrong:

  • A - Omitting column names is valid SQL as long as values are provided in the correct order; it does not cause a type mismatch.
  • B - YYYY-MM-DD is a standard and accepted date format in Snowflake, so it would not cause an error.
  • D - dept_id would only be an issue if its value were non-numeric and the column required an integer; nothing in the question establishes this.
  • E - A semicolon terminating a statement is correct SQL syntax and does not cause errors.

Memory tip: Think of it as trying to deposit "Five Thousand dollars" as words into a bank account that only accepts numbers - the system doesn't know what to do with text where a numeric value is expected. Whenever you see a quoted word representing a number in an INSERT statement, flag it as a type mismatch risk.

Topics

#Type conversion error#INSERT statement#NUMBER data type#String literal

Community Discussion

No community discussion yet for this question.

Full SOL-C01 Practice