Microsoft SQL Server Database Quiz Questions

Chapter Name:Chapter 7 - DQL (Data Query Language)
Lesson Content Link:STRING functions
Current Quiz Count:45
Progress
0%
Q1
True / False

The STRING_AGG function concatenates values from multiple rows into a single string.

Q2
True / False

The LEFT function extracts a specified number of characters from the start of a string.

Q3
True / False

The REVERSE function is used to convert all characters in a string to uppercase.

Q4
True / False

The CHARINDEX function returns the starting position of a substring within a string.

Q5
True / False

The REPLACE function is used to remove all occurrences of a substring from a string.

Q6
True / False

The LEN function returns the number of characters in a string, excluding trailing spaces.

SQL Code
SELECT LEN(' SQL Server ');
Q7
True / False

The RTRIM function removes trailing spaces from a string.

SQL Code
SELECT RTRIM(' SQL Server ');
Q8
True / False

The CONCAT function can combine multiple strings into a single string.

SQL Code
SELECT CONCAT('SQL', ' ', 'Server');
Q9
True / False

The FORMAT function can be used to format date and time values as strings.

SQL Code
SELECT FORMAT(GETDATE(), 'yyyy-MM-dd');
Q10
True / False

The SUBSTRING function extracts a substring from a string starting at a specified position.

SQL Code
SELECT SUBSTRING('SQL Server', 1, 3);
Q11
True / False

The LOWER function converts all characters in a string to lowercase.

SQL Code
SELECT LOWER('SQL SERVER');
Q12
True / False

The PATINDEX function returns the starting position of a pattern in a string, or zero if the pattern is not found.

SQL Code
SELECT PATINDEX('%Server%', 'SQL Server');
Q13
True / False

The QUOTENAME function adds square brackets or other delimiters to a string.

SQL Code
SELECT QUOTENAME('SQL Server');
Q14
True / False

The TRIM function removes both leading and trailing spaces from a string.

SQL Code
SELECT TRIM(' SQL Server ');
Q15
True / False

The STUFF function deletes a specified length of characters in a string and inserts another set of characters at a specified starting position.

SQL Code
SELECT STUFF('SQL Server', 5, 6, 'Database');
Q16
Single Choice

What does the LEN function return when applied to ' SQL Server '?

SQL Code
SELECT LEN(' SQL Server ');
Q17
Single Choice

Which function would you use to replace all occurrences of 'Server' with 'Database' in a string?

SQL Code
SELECT REPLACE('SQL Server is great', 'Server', 'Database');
Q18
Single Choice

How would you extract the first three characters of 'SQL Server'?

SQL Code
SELECT LEFT('SQL Server', 3);
Q19
Single Choice

Which function can be used to concatenate 'SQL' and 'Server' with a space in between?

SQL Code
SELECT CONCAT('SQL', ' ', 'Server');
Q20
Single Choice

What does the RTRIM function do to the string ' SQL Server '?

SQL Code
SELECT RTRIM(' SQL Server ');
Q21
Single Choice

Which function would you use to find the position of the substring 'Server' in 'SQL Server'?

SQL Code
SELECT CHARINDEX('Server', 'SQL Server');
Q22
Single Choice

Which function reverses the string 'SQL Server'?

SQL Code
SELECT REVERSE('SQL Server');
Q23
Single Choice

How can you convert all characters in 'SQL Server' to uppercase?

SQL Code
SELECT UPPER('SQL Server');
Q24
Single Choice

What does the LTRIM function do to the string ' SQL Server '?

SQL Code
SELECT LTRIM(' SQL Server ');
Q25
Single Choice

Which function can format the current date as 'YYYY-MM-DD'?

SQL Code
SELECT FORMAT(GETDATE(), 'yyyy-MM-dd');
Q26
Single Choice

What does the SUBSTRING function return for 'SQL Server', starting at position 5 for 6 characters?

SQL Code
SELECT SUBSTRING('SQL Server', 5, 6);
Q27
Single Choice

Which function removes leading and trailing spaces from a string?

SQL Code
SELECT TRIM(' SQL Server ');
Q28
Single Choice

How can you find the length of 'SQL Server'?

SQL Code
SELECT LEN('SQL Server');
Q29
Single Choice

Which function returns the Unicode value of the first character in a string?

SQL Code
SELECT UNICODE('SQL Server');
Q30
Single Choice

Which function removes a specified length of characters from a string and inserts another set of characters at a specified starting position?

SQL Code
SELECT STUFF('SQL Server', 5, 6, 'Database');
Q31
Multiple Choice

Which functions can be used to trim leading and trailing spaces from a string?

SQL Code
SELECT LTRIM(' SQL Server ');
SELECT RTRIM(' SQL Server ');
SELECT TRIM(' SQL Server ');
Q32
Multiple Choice

Which functions can be used to extract a substring from a string?

SQL Code
SELECT SUBSTRING('SQL Server', 1, 3);
SELECT LEFT('SQL Server', 3);
SELECT RIGHT('SQL Server', 6);
Q33
Multiple Choice

Which functions can be used to concatenate strings?

SQL Code
SELECT CONCAT('SQL', ' ', 'Server');
SELECT STRING_AGG(column_name, ' ') FROM table_name;
Q34
Multiple Choice

Which functions can change the case of characters in a string?

SQL Code
SELECT UPPER('sql server');
SELECT LOWER('SQL SERVER');
Q35
Multiple Choice

Which functions can return the starting position of a substring within a string?

SQL Code
SELECT CHARINDEX('Server', 'SQL Server');
SELECT PATINDEX('%Server%', 'SQL Server');
Q36
Multiple Choice

Which functions can be used to format date and time values as strings?

SQL Code
SELECT FORMAT(GETDATE(), 'yyyy-MM-dd');
Q37
Multiple Choice

Which functions can be used to find the length of a string?

SQL Code
SELECT LEN('SQL Server');
Q38
Multiple Choice

Which functions can be used to remove a specified length of characters from a string and insert another set of characters?

SQL Code
SELECT STUFF('SQL Server', 5, 6, 'Database');
SELECT REPLACE('SQL Server', 'Server', 'Database');
Q39
Multiple Choice

Which functions can be used to return the reverse of a string?

SQL Code
SELECT REVERSE('SQL Server');
Q40
Multiple Choice

Which functions can convert strings to Unicode?

SQL Code
SELECT N'Unicode String';
Q41
Multiple Choice

Which functions can add delimiters to a string?

SQL Code
SELECT QUOTENAME('SQL Server');
Q42
Multiple Choice

Which functions can be used to convert characters in a string to lowercase?

SQL Code
SELECT LOWER('SQL SERVER');
Q43
Multiple Choice

Which functions can be used to find the position of a pattern in a string?

SQL Code
SELECT PATINDEX('%Server%', 'SQL Server');
Q44
Multiple Choice

Which functions can return the first character of a string?

SQL Code
SELECT LEFT('SQL Server', 1);
Q45
Multiple Choice

Which functions can remove characters from a string?

SQL Code
SELECT STUFF('SQL Server', 5, 6, '');
SELECT REPLACE('SQL Server', 'Server', '');