nerdexam
SnowflakeSnowflake

SOL-C01 · Question #166

SOL-C01 Question #166: Real Exam Question with Answer & Explanation

The correct answer is A: Replace each single quote (') with two single quotes (") in the `EMP NAME' values before. Option A is a standard SQL practice to escape single quotes within a string literal by replacing them with two single quotes. Option C is another secure and effective approach. Parameterized queries or prepared statements handle the escaping of special characters automatically, p

Data Loading and Unloading

Question

You are loading data into a Snowflake table 'EMPLOYEE DATA (EMP_ID INT, EMP NAME VARCHAR, DEPARTMENT VARCHAR)' using 'INSERT' statements. You notice that some of the 'EMP NAME values in your source data contain single quotes ('). Which of the following methods can you use to ensure that these values are correctly inserted into the table without causing syntax errors?

Options

  • AReplace each single quote (') with two single quotes (") in the `EMP NAME' values before
  • BEnclose the ` EMP_NAME values in double quotes (") instead of single quotes in the `INSERT
  • CUse parameterized queries or prepared statements to insert the data.
  • DBefore inserting, use 'REPLACE(EMP NAME, "", in the INSERT statement to escape the single
  • ERemove special characters and single quotes from all EMP_NAME.

Explanation

Option A is a standard SQL practice to escape single quotes within a string literal by replacing them with two single quotes. Option C is another secure and effective approach. Parameterized queries or prepared statements handle the escaping of special characters automatically, preventing SQL injection vulnerabilities and ensuring data integrity. Option B doesn't work. In Snowflake, you can't use double quotes to escape single quotes within a string literal. Option D will work in some SQL dialects but may not work in all versions. Option E changes the meaning of

Topics

#Data Loading#SQL Syntax#String Escaping#Parameterized Queries

Community Discussion

No community discussion yet for this question.

Full SOL-C01 PracticeBrowse All SOL-C01 Questions