Microsoft SQL Server Database Quiz Questions

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

The CONCAT function can concatenate multiple string values in SQL Server.

SQL Code
SELECT CONCAT('Hello', ' ', 'World');
SELECT CONCAT('Good', ' ', 'Morning');
SELECT CONCAT('SQL', ' ', 'Server');
SELECT CONCAT('Database', ' ', 'Management');
Q2
True / False

The CONCAT function requires at least three arguments.

SQL Code
SELECT CONCAT('Hello', 'World');
SELECT CONCAT('123', '456');
SELECT CONCAT('abc', 'def');
SELECT CONCAT('foo', 'bar');
Q3
True / False

CONCAT can be used to concatenate NULL values without resulting in a NULL output.

SQL Code
SELECT CONCAT('Hello', NULL, 'World');
SELECT CONCAT('Good', NULL, 'Morning');
SELECT CONCAT('SQL', NULL, 'Server');
SELECT CONCAT('Database', NULL, 'Management');
Q4
True / False

Using CONCAT with an integer will result in an error.

SQL Code
SELECT CONCAT('The number is ', 123);
SELECT CONCAT('Value: ', 456);
SELECT CONCAT('ID: ', 789);
SELECT CONCAT('Code: ', 101112);
Q5
True / False

The CONCAT function can concatenate columns of different data types.

SQL Code
SELECT CONCAT(first_name, ' ', age) FROM users;
SELECT CONCAT(last_name, ' ', salary) FROM employees;
SELECT CONCAT(product_name, ' ', price) FROM products;
SELECT CONCAT(department_name, ' ', budget) FROM departments;
Q6
True / False

The CONCAT function is case-sensitive.

SQL Code
SELECT CONCAT('hello', 'WORLD');
SELECT CONCAT('GOOD', 'morning');
SELECT CONCAT('sql', 'SERVER');
SELECT CONCAT('database', 'MANAGEMENT');
Q7
True / False

CONCAT can be used in the SELECT clause to create a full name from first_name and last_name columns.

SQL Code
SELECT CONCAT(first_name, ' ', last_name) AS full_name
FROM employees;
SELECT CONCAT(first_name, ' ', middle_name, ' ', last_name) AS full_name
FROM employees;
Q8
True / False

CONCAT cannot be used to concatenate more than two columns.

SQL Code
SELECT CONCAT(first_name, ' ', middle_name, ' ', last_name)
FROM employees;
SELECT CONCAT(title, ' - ', description)
FROM products;
SELECT CONCAT(city, ', ', state, ' ', zip)
FROM addresses;
SELECT CONCAT(make, ' ', model, ' (', year, ')')
FROM vehicles;
Q9
True / False

The CONCAT function can be used with the WHERE clause.

SQL Code
SELECT * FROM users
WHERE CONCAT(first_name, ' ', last_name) = 'John Doe';
SELECT * FROM customers
WHERE CONCAT(city, ', ', state) = 'New York, NY';
SELECT * FROM products
WHERE CONCAT(title, ' - ', category) = 'Widget - Tools';
SELECT * FROM orders
WHERE CONCAT(order_id, '-', customer_id) = '123-456';
Q10
True / False

The CONCAT function can handle both strings and numbers without explicit conversion.

SQL Code
SELECT CONCAT('Age: ', age) FROM users;
SELECT CONCAT('Order #: ', order_id) FROM orders;
SELECT CONCAT('Price: $', price) FROM products;
SELECT CONCAT('Stock: ', quantity) FROM inventory;
Q11
True / False

Using CONCAT with NULL values will always result in NULL.

SQL Code
SELECT CONCAT('Value is ', NULL);
SELECT CONCAT('Name: ', NULL);
SELECT CONCAT('Date: ', NULL);
SELECT CONCAT('Status: ', NULL);
Q12
True / False

You cannot use CONCAT to combine text and date values.

SQL Code
SELECT CONCAT('Date: ', order_date) FROM orders;
SELECT CONCAT('Delivery: ', delivery_date) FROM shipments;
SELECT CONCAT('Birthday: ', birth_date) FROM users;
SELECT CONCAT('Event Date: ', event_date) FROM events;
Q13
True / False

The result of CONCAT('A', 'B', 'C') is 'ABC'.

SQL Code
SELECT CONCAT('A', 'B', 'C');
SELECT CONCAT('1', '2', '3');
SELECT CONCAT('X', 'Y', 'Z');
SELECT CONCAT('!', '@', '#');
Q14
True / False

The CONCAT function can be used within a CASE statement.

SQL Code
SELECT CASE
 WHEN condition THEN CONCAT('Value: ', value)
 ELSE 'No Value'
END
FROM table;
Q15
True / False

CONCAT_WS is a variation of CONCAT that allows specifying a separator.

SQL Code
SELECT CONCAT_WS('-', 'A', 'B', 'C');
SELECT CONCAT_WS(',', '1', '2', '3');
SELECT CONCAT_WS(';', 'X', 'Y', 'Z');
SELECT CONCAT_WS(' ', 'Hello', 'World');
Q16
Single Choice

How do you use the CONCAT function to combine first_name and last_name with a space in between?

SQL Code
SELECT CONCAT(first_name, ' ', last_name) AS full_name
FROM users;
SELECT CONCAT(first_name, middle_name, last_name) AS full_name
FROM employees;
Q17
Single Choice

Which query uses CONCAT to create a full name from the first_name and last_name columns?

SQL Code
SELECT CONCAT(first_name, ' ', last_name) AS full_name
FROM employees;
SELECT CONCAT(first_name, middle_name, last_name) AS full_name
FROM employees;
Q18
Single Choice

How do you use CONCAT to format a full address from street, city, and state columns?

SQL Code
SELECT CONCAT(street, ', ', city, ', ', state) AS full_address
FROM addresses;
SELECT CONCAT(city, ', ', state, ' ', zip) AS full_address
FROM addresses;
Q19
Single Choice

How do you use CONCAT to display a product's full name as 'Product: <product_name>'?

SQL Code
SELECT CONCAT('Product: ', product_name) AS full_name
FROM products;
SELECT CONCAT(product_name, ' - ', category) AS full_name
FROM products;
Q20
Single Choice

How do you use CONCAT to create a label for an order as 'Order ID: <order_id>'?

SQL Code
SELECT CONCAT('Order ID: ', order_id) AS label
FROM orders;
SELECT CONCAT('Order: ', order_id) AS label
FROM orders;
Q21
Single Choice

How do you use CONCAT to combine the first_name, middle_name, and last_name columns with spaces in between?

SQL Code
SELECT CONCAT(first_name, ' ', middle_name, ' ', last_name) AS full_name
FROM employees;
SELECT CONCAT(first_name, middle_name, last_name) AS full_name
FROM employees;
Q22
Single Choice

How do you use CONCAT to format a date as 'Year: <year>'?

SQL Code
SELECT CONCAT('Year: ', YEAR(order_date)) AS formatted_date
FROM orders;
SELECT CONCAT('Month: ', MONTH(order_date)) AS formatted_date
FROM orders;
Q23
Single Choice

How do you use CONCAT to display a user's age as 'Age: <age>'?

SQL Code
SELECT CONCAT('Age: ', age) AS display_age
FROM users;
SELECT CONCAT('User Age: ', age) AS display_age
FROM users;
Q24
Single Choice

How do you use CONCAT to create a product label as 'Product - <product_name>'?

SQL Code
SELECT CONCAT('Product - ', product_name) AS label
FROM products;
SELECT CONCAT('Product: ', product_name) AS label
FROM products;
Q25
Single Choice

How do you use CONCAT to create a customer's full address as 'Address: <street>, <city>, <state> <zip>'?

SQL Code
SELECT CONCAT('Address: ', street, ', ', city, ', ', state, ' ', zip) AS full_address
FROM customers;
SELECT CONCAT(street, ', ', city, ', ', state, ' ', zip) AS full_address
FROM customers;
Q26
Single Choice

How do you use CONCAT to display a contact number as 'Contact: <phone_number>'?

SQL Code
SELECT CONCAT('Contact: ', phone_number) AS contact_info
FROM contacts;
SELECT CONCAT('Phone: ', phone_number) AS contact_info
FROM contacts;
Q27
Single Choice

How do you use CONCAT to display a user's profile as 'Profile: <username>'?

SQL Code
SELECT CONCAT('Profile: ', username) AS profile_info
FROM users;
SELECT CONCAT('User: ', username) AS profile_info
FROM users;
Q28
Single Choice

How do you use CONCAT to create a greeting as 'Hello, <first_name>!'?

SQL Code
SELECT CONCAT('Hello, ', first_name, '!') AS greeting
FROM users;
SELECT CONCAT('Hi, ', first_name, '!') AS greeting
FROM users;
Q29
Single Choice

How do you use CONCAT to format an employee's ID and name as 'ID: <employee_id> - Name: <first_name> <last_name>'?

SQL Code
SELECT CONCAT('ID: ', employee_id, ' - Name: ', first_name, ' ', last_name) AS employee_info
FROM employees;
SELECT CONCAT('Employee: ', first_name, ' ', last_name) AS employee_info
FROM employees;
Q30
Single Choice

How do you use CONCAT to create a label for an inventory item as 'Item: <item_name> - Stock: <quantity>'?

SQL Code
SELECT CONCAT('Item: ', item_name, ' - Stock: ', quantity) AS inventory_label
FROM inventory;
SELECT CONCAT('Product: ', item_name, ' - Quantity: ', quantity) AS inventory_label
FROM inventory;
Q31
Single Choice

How do you use CONCAT to create a formatted string as 'Course: <course_name> - Duration: <duration> hours'?

SQL Code
SELECT CONCAT('Course: ', course_name, ' - Duration: ', duration, ' hours') AS course_info
FROM courses;
SELECT CONCAT('Program: ', course_name, ' - Length: ', duration, ' hrs') AS course_info
FROM courses;
Q32
Single Choice

How do you use CONCAT to format a date as 'Day: <day> - Month: <month> - Year: <year>'?

SQL Code
SELECT CONCAT('Day: ', DAY(order_date), ' - Month: ', MONTH(order_date), ' - Year: ', YEAR(order_date)) AS formatted_date
FROM orders;
SELECT CONCAT('Order Date: ', order_date) AS formatted_date
FROM orders;
Q33
Single Choice

How do you use CONCAT to display a department's name and code as 'Dept: <department_name> (Code: <department_code>)'?

SQL Code
SELECT CONCAT('Dept: ', department_name, ' (Code: ', department_code, ')') AS department_info
FROM departments;
SELECT CONCAT('Department: ', department_name, ' - Code: ', department_code) AS department_info
FROM departments;
Q34
Single Choice

How do you use CONCAT to create a product label as 'Product: <product_name> - Category: <category>'?

SQL Code
SELECT CONCAT('Product: ', product_name, ' - Category: ', category) AS product_info
FROM products;
SELECT CONCAT('Item: ', product_name, ' - Category: ', category) AS product_info
FROM products;
Q35
Single Choice

How do you use CONCAT to display a book's title and author as 'Title: <book_title> - Author: <author_name>'?

SQL Code
SELECT CONCAT('Title: ', book_title, ' - Author: ', author_name) AS book_info
FROM books;
SELECT CONCAT('Book: ', book_title, ' - Writer: ', author_name) AS book_info
FROM books;
Q36
Single Choice

How do you use CONCAT to display a movie's title and director as 'Movie: <movie_title> - Director: <director_name>'?

SQL Code
SELECT CONCAT('Movie: ', movie_title, ' - Director: ', director_name) AS movie_info
FROM movies;
SELECT CONCAT('Film: ', movie_title, ' - Directed by: ', director_name) AS movie_info
FROM movies;
Q37
Single Choice

How do you use CONCAT to create a formatted string as 'Date: <day>/<month>/<year>'?

SQL Code
SELECT CONCAT('Date: ', DAY(order_date), '/', MONTH(order_date), '/', YEAR(order_date)) AS formatted_date
FROM orders;
SELECT CONCAT('Order Date: ', order_date) AS formatted_date
FROM orders;
Q38
Single Choice

How do you use CONCAT to display a car's make and model as 'Car: <make> <model>'?

SQL Code
SELECT CONCAT('Car: ', make, ' ', model) AS car_info
FROM cars;
SELECT CONCAT('Vehicle: ', make, ' ', model) AS car_info
FROM cars;
Q39
Single Choice

How do you use CONCAT to format an order number and date as 'Order #: <order_number> - Date: <order_date>'?

SQL Code
SELECT CONCAT('Order #: ', order_number, ' - Date: ', order_date) AS order_info
FROM orders;
SELECT CONCAT('Order: ', order_number, ' - Date: ', order_date) AS order_info
FROM orders;
Q40
Single Choice

How do you use CONCAT to create a formatted string as 'Task: <task_name> - Due: <due_date>'?

SQL Code
SELECT CONCAT('Task: ', task_name, ' - Due: ', due_date) AS task_info
FROM tasks;
SELECT CONCAT('Task: ', task_name, ' - Deadline: ', due_date) AS task_info
FROM tasks;
Q41
Single Choice

How do you use CONCAT to format a movie title and release year as 'Title: <movie_title> (Year: <release_year>)'?

SQL Code
SELECT CONCAT('Title: ', movie_title, ' (Year: ', release_year, ')') AS movie_info
FROM movies;
SELECT CONCAT('Film: ', movie_title, ' - Released: ', release_year) AS movie_info
FROM movies;
Q42
Single Choice

How do you use CONCAT to create a formatted string as 'Event: <event_name> - Date: <event_date>'?

SQL Code
SELECT CONCAT('Event: ', event_name, ' - Date: ', event_date) AS event_info
FROM events;
SELECT CONCAT('Activity: ', event_name, ' - Date: ', event_date) AS event_info
FROM events;
Q43
Single Choice

How do you use CONCAT to display a person's name and age as 'Name: <first_name> <last_name> - Age: <age>'?

SQL Code
SELECT CONCAT('Name: ', first_name, ' ', last_name, ' - Age: ', age) AS person_info
FROM people;
SELECT CONCAT('Person: ', first_name, ' ', last_name, ' - Age: ', age) AS person_info
FROM people;
Q44
Single Choice

How do you use CONCAT to create a formatted string as 'Title: <book_title> by <author_name>'?

SQL Code
SELECT CONCAT('Title: ', book_title, ' by ', author_name) AS book_info
FROM books;
SELECT CONCAT('Book: ', book_title, ' - Author: ', author_name) AS book_info
FROM books;
Q45
Single Choice

How do you use CONCAT to display a company's name and location as 'Company: <company_name> - Location: <location>'?

SQL Code
SELECT CONCAT('Company: ', company_name, ' - Location: ', location) AS company_info
FROM companies;
SELECT CONCAT('Organization: ', company_name, ' - Location: ', location) AS company_info
FROM companies;