2 Answered Test Questions:
1. A company has the following departments:
marketing, Designing, production, Packing
What will be the result of the following query?
select * from table where department < 'marketing';
Answers:
• The query will return "Designing, Packing"
• The query will return "Designing, production, Packing"
• The query will return "packing"
• Strings cannot be compared using < operator
• The query will return "Designing"
2. Consider the following table structure of students:
rollno int
name varchar(20)
course varchar(20)
What will be the query to display the courses in which the number of students
enrolled is more than 5?
Answers:
• Select course from students where count(course) > 5;
• Select course from students where count(*) > 5 group by course;
• Select course from students group by course;
• Select course from students group by course having count(*) > 5;
• Select course from students group by course where count(*) > 5;
• Select course from students where count(group(course)) > 5;
• Select count(course) > 5 from students;
• None of the above
85 NOT Answered Yet Test Questions:
(hold on, will be updated soon)
3. Consider the query:
SELECT name
FROM Student
WHERE name LIKE '_a%';
Which names will be displayed?
Answers:
• Names starting with "a"
• Names containing "a" as the second letter
• Names starting with "a" or "A"
• Names containing "a" as any letter except the first
4. Which of the following is not a SQL operator?
Answers:
• Between..and..
• Like
• In
• Is null
• Having
• Not in
5. What is the maximum value that can be stored for a datetime field?
Answers:
• Dec 31, 9999
• Jun 6, 2079
• Jan 1, 2753
• Jan 1, 2100
6. Consider the following tables:
Books
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book on a scale of 1 to 10)
Language (such as French, English, German etc)
Subjects
---------
SubjectId
Subject (such as History, Geography, Mathematics etc)
Authors
--------
AuthorId
AuthorName
Country
Which of the following queries will return the the most popular books written in French?
Answers:
• select bookname from books where language='French' and popularityrating = (select max(popularityrating) from books where language='French')
• select bookname from books where language='French' and popularityrating = (select max(popularityrating) from books Having language='French')
• select bookname,max(popularityrating) from books where language='French' and max(popularityrating)
• select bookname,max(popularityrating) from books where language='French' having max(popularityrating)
7. Which of the following is not a column property?
Answers:
• Null
• Not Null
• Default
• Identity
8. Which one of the following fields is the ideal candidate for the primary key in a student record base?
Answers:
• Parent's name
• Address
• System generated ID
• Student name
• Phone number
9. Which of the following are not date parts?
Answers:
• quarter
• dayofweek
• dayofyear
• weekday
10. You want to display the titles of books that meet the following criteria:
1. Purchased before November 11, 2002
2. Price is less than $500 or greater than $900
You want to sort the result by the date of purchase, starting with the most recently bought book.
Which of the following statements should you use?
Answers:
• SELECT book_title FROM books WHERE price between 500 and 900 AND purchase_date < '11/11/2002' ORDER BY purchase_date;
• SELECT book_title FROM books WHERE price IN (500, 900) AND purchase_date < '11/11/2002' ORDER BY purchase date ASC;
• SELECT book_title FROM books WHERE (price < 500 OR > 900) AND purchase_date DESC;
• SELECT Book_title FROM books WHERE (price < 500 OR price > 900) AND purchase_date < '11/11/2002' ORDER BY purchase_date DESC;
11. Consider the following tables:
Books
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book on a scale of 1 to 10)
Language (such as French, English, German etc)
Subjects
---------
SubjectId
Subject (such as History, Geography, Mathematics etc)
Authors
--------
AuthorId
AuthorName
Country
What is the query to determine how many books, with a popularity rating of more than 7, have been written on each subject?
Answers:
• select subject,count(*) as Books from books,subjects where books.popularityrating > 7 group by subjects.subject
• select subject,count(*) as Books from books,subjects where books.authorid=subjects.authorid and books.popularityrating > 7 group by subjects.subject
• select subject,count(*) as Books from books,subjects where books.subjectid=subjects.subjectid and books.popularityrating = 7 group by subjects.subject
• select subject,count(*) as Books from books,subjects where books.subjectid=subjects.subjectid and books.popularityrating > 7 group by subjects.subject
12. What will happen if you query the emp table as shown below:
select empno, DISTINCT ename, Salary from emp;
Answers:
• EMPNO, unique value of ENAME and then SALARY are displayed
• EMPNO, unique value ENAME and unique value of SALARY are displayed
• DISTINCT is not a valid keyword in SQL
• No values will be displayed because the statement will return an error
13. You should avoid the use of cursors because:
Answers:
• They are very difficult to implement
• Programs with cursors take more time to run, hence performance degrades
• programs with cursors are more lengthy, hence they consume more space/memory
• No, you must maximize the use of cursors because they improve performance
14. Which of the following statements about SQL Server comments is false?
Answers:
• /* ... */ are used for multiline comments
• // is used for single line comments
• -- is used for single line comments
• Nested comments are allowed i.e. /* comment 1 /* comment 2 */ comment 1*/
• ' is used for single line comments
15. State which of the following are true
Answers:
• Views are a logical way of looking at the logical data located in the tables
• Views are a logical way of looking at the physical data located in the tables
• Tables are physical constructs used for storage and manipulation of data in databases
• Tables are logical constructs used for storage and manipulation of data in databases
16. The AND operator displays a row if ANY conditions listed are true. The OR operator displays a row if ALL of the conditions listed are true
Answers:
• True
• False
17. Which of the following are false for batches (batch commands)?
Answers:
• Statements in a batch are parsed, compiled and executed as a group
• None of the statements in the batch is executed if there are any syntax errors in the batch
• None of the statements in the batch is executed if there are any parsing errors in the batch
• None of the statements in the batch is executed if there are any fatal errors in the batch
18. Does SQL Server support user-defined datatypes?
Answers:
• No, SQL doesn't support user-defined datatypes
• Yes, but it allows the user to subclass an existing datatype only
• Yes, it allows a user to define new datatypes without new storage characterstics
• Yes, it allows a user to define new datatypes with new storage characteristics
19. Consider the transaction:
Begin Transaction
Create table A ( x smallint , y smallint )
Create table B ( p smallint , q smallint )
Update A set x=600 where y > 700
Update B set p=78 where q=99
If @@ error != 0
Begin
RollBack Transaction
Return
End
Commit Transaction
Select the correct option:
Answers:
• The transaction will work perfectly fine
• It will report an error
• The error handling routine contains a syntax error
• None of the above
• Both b and c
20. What is the correct order of clauses in the select statement?
1 select
2 order by
3 where
4 having
5 group by
Answers:
• 1,2,3,4,5
• 1,3,5,4,2
• 1,3,5,2,4
• 1,3,2,5,4
• 1,3,2,4,5
• 1,5,2,3,4
• 1,4,2,3,5
• 1,4,3,2,5
21. Is the FROM clause necessary in every SELECT statement?
Answers:
• Yes
• No
22. Which of the following statements is not true about the table object in SQL Server?
Answers:
• A table can have only 1024 columns
• Multiple Tables with the same name can be created within the same database
• A column in a table can have the same name as that of the table
• All statements are true
• All statements are false
23. How can you view the structure of a table named "myTable" in SQL Server?
Answers:
• desc myTable
• desc table myTable
• sp_columns myTable
• None of the above
• Using either option a or c
24. Which of the following datatypes is not supported by SQL-Server?
Answers:
• Character
• Binary
• Logical
• Date
• Numeric
• All are supported
25. Examine the data in the EMPLOYEES table given below:
LAST_NAME DEPARTMENT_ID SALARY
ALLEN 10 3000
MILLER 20 1500
King 20 2200
Davis 30 5000
Which of the following Subqueries work?
Answers:
• SELECT * FROM employees where salary > (SELECT MIN(salary) FROM employees GROUP BY department_id);
• SELECT * FROM employees WHERE salary = (SELECT AVG(salary) FROM employees GROUP BY department_id);
• SELECT distinct department_id FROM employees Where salary > ANY (SELECT AVG(salary) FROM employees GROUP BY department_id);
• SELECT department_id FROM employees WHERE SALARY > ALL (SELECT AVG(salary) FROM employees GROUP BY department_id);
• SELECT department_id FROM employees WHERE salary > ALL (SELECT AVG(salary) FROM employees GROUP BY AVG(SALARY));
26. What does referential integrity (also called relational integrity) prevent?
Answers:
• Loss of data from employee sabotage
• Loss of data from any one corrupted table
• Recursive joins
• One-to-many or many-to-many relationships between columns in a table
• Data redundancy
27. Consider the following tables:
Books
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book on a scale of 1 to 10)
Language (such as French, English, German etc)
Subjects
---------
SubjectId
Subject (such as History, Geography, Mathematics etc)
Authors
--------
AuthorId
AuthorName
Country
What is the query to determine how many books have been written on each subject. Displaying Name of Subject and count of the Books?
Answers:
• select subject,count(*) from books,subjects where books.subjectid=subjects.subjectid group by books.subjectid
• select subject,count(*) from books,subjects where books.subjectid=subjects.subjectid group by books.subjectid,subjects.subject
• select subject,count(*) from books,subjects where books.Authorid=subjects.Authorid group by books.subjectid,subjects.subject
• select subject,count(*) from books,subjects where books.BookId=subjects.BookId group by books.subjectid,subjects.subject
28. What is the correct SQL syntax for returning all the columns from a table named "Persons" sorted REVERSE alphabetically by "FirstName"?
Answers:
• SELECT * FROM Persons WHERE FirstName ORDER BY FirstName DESC
• SELECT * FROM Persons SORT REVERSE 'FirstName'
• SELECT * FROM Persons ORDER BY -'FirstName'
• SELECT * FROM Persons ORDER BY FirstName DESC
29. The simplest query must include at least ________ and _________.
Answers:
• A select clause
• A where clause
• A from clause
• A group by clause
• A having clause
• An order by clause
30. Which of the following options is not correct about the DATEDIFF() function?
Answers:
• It returns the difference between parts of two specified dates
• It takes three arguments
• It returns a signed integer value equal to second date part minus first date part
• It returns a signed integer value equal to first date part minus second date part
31. The STUDENT_GRADES table has these columns:
STUDENT_ID INT
SEMESTER_END DATETIME
GPA FLOAT
Which of the following statements finds the highest Grade Point Average (GPA) per semester?
Answers:
• SELECT MAX(gpa) FROM student_grades WHERE gpa IS NOT NULL
• SELECT (gpa) FROM student_grades GROUP BY semester_end WHERE gpa IS NOT NULL
• SELECT MAX(gpa) FROM student_grades WHERE gpa IS NOT NULL GROUP BY semester_end
• SELECT MAX(gpa) GROUP BY semester_end WHERE gpa IS NOT NULL FROM student_grades
• SELECT MAX(gpa) FROM student_grades GROUP BY semester_end WHERE gpa IS NOT NULL
32. Is this statement true or false:
A cursor is a pointer that identifies a specific working row within a set
Answers:
• True
• False
33. Which of the following is/are true with reference to Triggers?
Answers:
• A trigger cannot maintain cascading referential integrity
• Manipulating columns of datatype IMAGE / TEXT does not cause triggers to be executed
• Only the database owner can create triggers
• Triggers are executed on INSERT, UPDATE, DELETE and SELECT statements
34. Which of the following constraints can be used to enforce the uniqueness of rows in a table?
Answers:
• DEFAULT and NOT NULL constraints
• FOREIGN KEY constraints
• PRIMARY KEY and UNIQUE constraints
• IDENTITY columns
• CHECK constraints
35. Is the following statement true or false?
A column that allows NULLs requires more space to store a value.
Answers:
• True
• False
36. You are maintaing data for its products in the Products table, and wants to see the products which are 50 or more numbers far from the minimum stock limit. The structure of the Products table is:
ProductID
ProductName
CurrentStock
MinimumStock
Two possible queries are:
(a)select * from products where currentStock > MinimumStock + 50
(b)select * from products where currentStock - 50 > MinimumStock
Choose the appropriate option with regard to the above queries.
Answers:
• (a) is correct
• (b) is correct
• (a) and (b) both are correct
• (a) and (b) both are incorrect
37. In which sequence are queries and sub-queries executed by the SQL Engine?
Answers:
• primary query -> sub query -> sub sub query and so on
• sub sub query -> sub query -> prime query
• the whole query is interpreted at one time
• there is no fixed sequence of interpretation, the query parser takes a decision on the fly
38. Which of the following commands is used to change the structure of table?
Answers:
• CHANGE TABLE
• MODIFY TABLE
• ALTER TABLE
• UPDATE TABLE
39. Which one of the following must be specified in every DELETE statement?
Answers:
• Table Name
• Database name
• LIMIT clause
• WHERE clause
• Column Names
40. What is the correct SQL syntax for selecting all the columns where the "LastName" is alphabetically between (and including) "Hansen" and "Pettersen"?
Answers:
• SELECT * FROM Persons WHERE LastName > 'Hansen', LastName < 'Pettersen'
• SELECT LastName > 'Hansen' AND LastName < 'Pettersen' FROM Persons
• SELECT * FROM customers WHERE LastName > 'Hansen' AND LastName > 'Pettersen'
• SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'
41. Which of the following is false with regards to sp_help?
Answers:
• When a procedure name is passed to sp_help, it shows the parameters
• When a table name is passed to sp_help, it shows the structure of the table
• When no parameter is passed, it provides a list of all objects and user-defined datatypes in a database
• All of the above are true
42. What is the order of precedence among the following operators?
1 IN
2 NOT
3 AND
4 OR
Answers:
• 1,2,3,4
• 2,3,4,1
• 1,2,4,3
• 1,4,3,2
• 4,3,2,1
• 4,1,2,3
• 4,2,1,3
• 3,2,1,4
43. Is it possible to insert several rows into a table with a single INSERT statement?
Answers:
• No
• Yes
44. Which of the following is not a control statement?
Answers:
• if...else
• if exists
• do...while
• while
• begin...end
45. Which of the following is not a global variable?
Answers:
• @@colcount
• @@error
• @@rowcount
• @@version
• All are valid global variables
46. A production house needs a sale report where total sale of the day is more than $20,000. Which of the following query should be used?
Answers:
• select OrderDate,Amount from orders where sum(amount) > 20000
• select OrderDate,Amount from orders where sum(amount) > 20000 order by OrderDate
• select count(OrderDate),sum(amount) from orders group by OrderDate having sum(amount) > 20000
• select count(OrderDate),sum(amount) from orders group by OrderDate where sum(amount) > 20000
47. When designing a database table, how do you avoid missing column values for non-primary key columns?
Answers:
• Use UNIQUE constraints
• Use PRIMARY KEY constraints
• Use DEFAULT and NOT NULL constraints
• Use FOREIGN KEY constraints
• Use SET constraints
48. Which of the following is an invalid statement for manipulation of binary data?
Answers:
• displaytext
• readtext
• writetext
• updatetext
49. Which of the following options is correct about identity(seed, increment)?
Answers:
• The increment parameter can never be negative
• The increment can be 0
• More than one columns in a table can be assigned the identity property
• The identity property value for a column assures uniqueness of a row
• None of the above
50. Which of the following is not a valid binary datatype in SQL Server?
Answers:
• BINARY
• VARBINARY
• BIT
• IMAGE
• TMESTAMP
51. Sample Code
CREATE TABLE table1(
column1 varchar(50),
column2 varchar(50),
column3 varchar(50),
column4 varchar(50));
Which one of the following is the correct syntax for adding the column named "column2a" to the table shown above?
Answers:
• ALTER TABLE table1 ADD column2a varchar(50);
• MODIFY TABLE table1 ADD column2a;
• INSERT INTO table1 column2a AS varchar(50);
• ALTER TABLE table1 INSERT column2a varchar(50);
• CHANGE TABLE table1 INSERT column2a;
52. The names of those departments where there are more than 100 employees have to be displayed. Given two relations, employees and departments, what query should be used?
Employee
---------
Empno
Employeename
Salary
Deptno
Department
---------
Deptno
Departname
Answers:
• Select departname from department where deptno in (select deptno from employee group by deptno having count(*) > 100);
• Select departname from department where deptno in (select count(*) from employee group by deptno where count(*) > 100);
• Select departname from department where count(deptno) > 100;
• Select departname from department where deptno in (select count(*) from employee where count(*) > 100);
53. A table has following values for its department field:
marketing, production, production, sales, NULL, NULL, Marketing, Null
What will the following query return:
Select distinct(department) from employees
Answers:
• marketing, production, sales
• marketing, production, sales, NULL
• marketing, production, sales, NULL, NULL
• marketing, production, sales, NULL, Marketing
• marketing, production, sales, NULL, NULL, Marketing
54. Which of the following is not a valid Arithmetic operator in SQL Server?
Answers:
• +
• -
• *
• \
• ^
55. It is time for the annual sales awards at your company. The awards include
certificates awarded for the five sales of the highest sale amounts. You need
to produce a list of the five highest revenue transactions from the Orders table
in the Sales database. The Orders table is defined as follows:
CREATE TABLE Orders (
OrderID Int IDENTITY NOT NULL,
SalesPersonID Int NOT NULL,
RegionID Int NOT NULL,
OrderDate Datetime NOT NULL,
OrderAmount Int NOT NULL )
Which statement will produce the report correctly?
Answers:
• SELECT TOP 5 OrderAmount, SalesPersonID FROM orders
• SELECT TOP 5 OrderAmount, SalesPersonID FROM orders ORDER BY OrderAmount DESC
• SELECT TOP 5 WITH TIES OrderAmount, SalesPersonID From Orders
• SELECT TOP 5 WITH TIES OrderAmount, SalesPersonID From Orders ORDER BY OrderAmount
56. What is the numeric range that is supported by the datatype tinyint?
Answers:
• 0-25
• 0-100�����
• 0-255
• 0-3276
57. Which one of the following correctly selects rows from the table myTable that have null in column column1?
Answers:
• SELECT * FROM myTable WHERE column1 is null
• SELECT * FROM myTable WHERE column1 = null
• SELECT * FROM myTable WHERE column1 EQUALS null
• SELECT * FROM myTable WHERE column1 NOT null
• SELECT * FROM myTable WHERE column1 CONTAINS null
58. Examine the two SQL statements given below:
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY salary DESC
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC
What is true about them?
Answers:
• The two statements produce identical results
• The second statement returns an error
• There is no need to specify DESC because the results are sorted in descending order by default
• None of the above
59. Which of the following statements are true?
Answers:
• soundex(Smith) is the same as soundex(Smithson)
• soundex(SMITH) is different from soundex(smith)
• soundex(smith) is the same as soundex(smyth)
• soundex(smith) is different from soundex(smythe)
• All are false
60. Which operator will be evaluated first in the following statement:
select (age + 3 * 4 / 2 - 8) from emp
Answers:
• +
• -
• /
• *
61. Examine the description of the STUDENTS table:
STD_ID INT
COURSE_ID VARCHAR (10)
START_DATE DATETIME
END_DATE DATETIME
The aggregate functions valid on the START_DATE column are:
Answers:
• SUM(start_date)
• AVG(start_date)
• COUNT(start_date)
• AVG(start_date, end_date)
• MIN(start_date)
62. Examine the code given below:
SELECT employee_id FROM employees WHERE commission_pct=.5 OR salary > 23000
Which of the following statements is correct with regard to this code?
Answers:
• It returns employees whose salary is 50% more than $23,000
• It returns employees who have 50% commission rate or salary greater than $23,000
• It returns employees whose salary is 50% less than $23,000
• None of the above
63. Choose the appropriate query for the Products table where data should be displayed primarily in ascending order of the ProductGroup column. Secondary sorting should be in descending order of the CurrentStock column.
Answers:
• Select * from Products order by CurrentStock,ProductGroup
• Select * from Products order by CurrentStock DESC,ProductGroup
• Select * from Products order by ProductGroup,CurrentStock
• Select * from Products order by ProductGroup,CurrentStock DESC
• None of the above
64. Which of the following is the syntax for creating an Index?
Answers:
• CREATE [UNIQUE] INDEX index_name OF tbl_name (index_columns)
• CREATE [UNIQUE] INDEX OF tbl_name (index_columns)
• CREATE [UNIQUE] INDEX ON tbl_name (index_columns)
• CREATE [UNIQUE] INDEX index_name ON tbl_name (index_columns)
65. The IF UPDATE (column_name) parameter in a trigger definition will return
TRUE in case of an INSERT statement being executed on the triggered table:
Answers:
• Yes
• No
• It returns TRUE only if an UPDATE query is executed
• Both b and c
66. Consider the following tables:
Books
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book on a scale of 1 to 10)
Language (such as French, English, German etc)
Subjects
---------
SubjectId
Subject (such as History, Geography, Mathematics etc)
Authors
--------
AuthorId
AuthorName
Country
What is the query to determine which Authors have written at least 1 book with a popularity rating of less than 5?
Answers:
• select authorname from authors where authorid in (select authorid from books where popularityrating<5)
• select authorname from authors where authorid in (select authorid from books where popularityrating<=5)
• select authorname from authors where authorid in (select BookId from books where popularityrating<5)
• select authorname from authors where authorid in (select authorid from books where popularityrating in (0,5))
67. View the following Create statement:
1 Create table Pers
2(EmpNo Int not null,
3 EName Char not null,
4 Join Datetime not null,
5 Pay Smallmoney)
Which line contains an error?
Answers:
• 1
• 2
• 3
• 4
• 5
68. Study the situation described below and identify the nature of relationship?
Each student can enroll into more than one class. Each class can accommodate more than one student.
Answers:
• 1 to N
• 1 to 1
• M to N to 1
• M to M
• N to 1
69. What is wrong with the following query:
select * from Orders where OrderID = (select OrderID from OrderItems where ItemQty > 50)
Answers:
• In the sub query, '*' should be used instead of 'OrderID'
• The sub query can return more than one row, so, '=' should be replaced with 'in'
• The sub query should not be in parenthesis
• None of the above
70. How can you change "Hansen" into "Nilsen" in the LastName column in the Persons
Table?
Answers:
• UPDATE Persons SET LastName = 'Nilsen' WHERE LastName = 'Hansen'
• UPDATE Persons SET LastName = 'Hansen' INTO LastName = 'Nilsen'
• SAVE Persons SET LastName = 'Nilsen' WHERE LastName = 'Hansen'
• SAVE Persons SET LastName = 'Hansen' INTO LastName = 'Nilsen'
71. What happens if you type the following statement at the T-SQL prompt?
SELECT getdate()
Answers:
• It will print the current date
• It will generate an 'Undefined Function' error message
• It will generate an 'Incorrect Syntax' error message because you cannot write a function name after SELECT
72. In a query, which of the following is/are executed first?
Answers:
• Parenthesis
• Multiplication, Division and Exponents
• Addition and Subtraction
• Logical Operations
73. Which of the following is not a valid character datatype in SQL Server?
Answers:
• BLOB
• CHAR
• VARCHAR
• TEXT
• VARTEXT
74. Consider the following two tables:
1. customers( customer_id, customer_name)
2. branch ( branch_id, branch_name )
What will be the output if the following query is executed:
Select *, branch_name from customers,branch
Answers:
• It will return the fields customer_id, customer_name, branch_name
• It will return the fields customer_id, customer_name, branch_id, branch_name
• It will return the fields customer_id, customer_name, branch_id, branch_name, branch_name
• It will return an empty set since the two tables do not have any common field name
• It will return an error since * is used alone for one table only
75. The sales database contains a customer table and an order table. For each order there is one and only one customer, and for each customer there can be zero or more orders. How should primary and foreign key fields be placed into the design of this database?
Answers:
• A primary key should be created for the customer_id field in the customer table and also for the customer_id field in the order table
• A primary key should be created for the order_id field in the customer table and also for the customer_id field in the order table
• A primary key should be created for the customer_id field in the customer table and a foreign key should be created for the customer_id field in the order table
• A primary key should be created for the customer_id field in the customer table and a foreign key should be created for the order_id field in the order table
• None of these
76. Evaluate the following SQL statement:
SELECT e.employee_id, (.15* e.salary) + (.5 * e.commission_pct) + (s.sales_amount * (.35 * e.bonus)) AS CALC_VALUE FROM employees e, sales s WHERE e.employee_id = s.emp_id;
What will happen if all the parentheses are removed from the calculation?
Answers:
• The value displayed in the CALC_VALUE column will be lower
• The value displayed in the CALC_VALUE column will be higher
• There will be no difference in the value displayed in the CALC_VALUE column
• An error will be reported
77. ___________ is the highest level of a transaction isolation implemented by SQL Server.
Answers:
• Read Uncommitted
• Read Committed
• Repeatable Read
• Serializable
78. Which of the following are aggregate functions in SQL?
Answers:
• Avg
• Select
• Order By
• Sum
• Union
• Group by
• Having
79. What does BLOB stand for?
Answers:
• Binary Large Object
• Binary Lower Byte
• Bit Large Object
• Bit Lower Byte
80. Which of the following queries is valid?
Answers:
• Select * from students where marks > avg(marks);
• Select * from students order by marks where subject = 'SQL';
• Select * from students having subject ='SQL';
• Select name from students group by subject, name;
• Select group(*) from students;
• Select name,avg(marks) from students;
• None of the above
81. Examine the query:-
select (2/2/4) from tab1;
where tab1 is a table with one row. This would give a result of:
Answers:
• 4
• 2
• 1
• .5
• .25
• 0
• 8
• 24
82. Consider the following queries:
1. select * from employee where department LIKE "[^F-M]%";
2. select * from employee where department = '[^F-M]%';
Select the correct option:
Answers:
• Query 2 will return an error
• Both the queries will return the same set of records
• Query 2 is perfectly correct
• Query 2 would return one record less than Query 1
83. Consider the following statements and pick the correct answer:
1. ceiling() - returns the smallest integer greater than or equal to the specified value
2. floor() - returns the largest integer less than or equal to the specified value
Answers:
• 1 is true and 2 is false
• 1 is false and 2 is true
• Both 1 and 2 are true
• Both 1 and 2 are false
84. Which query will display data from the Pers table relating to Analysts, Clerks and Salesmen who joined between 1/1/2005 and 1/2/2005?
Answers:
• select * from Pers where joining_date from '1/1/2005' to '1/2/2005', job='Analyst or clerk or salesman'
• select * from Pers where joining_date between '1/1/2005' to '1/2/2005', job='Analyst' or job='clerk' or job='salesman'
• select * from Pers where joining_date between '1/1/2005' and '1/2/2005' and (job='Analyst' or job='clerk' or job='salesman')
• None of the above
85. Consider the following tables:
Books
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book on a scale of 1 to 10)
Language (such as French, English, German etc)
Subjects
---------
SubjectId
Subject (such as History, Geography, Mathematics etc)
Authors
--------
AuthorId
AuthorName
Country
What is the query to determine the names of the Authors who have written more than 1 book?
Answers:
• select AuthorName from Authors where AuthorId in (select AuthorId from Books group by AuthorId having count(*)>1)
• select AuthorName from Authors, Books where Authors.AuthorId=Books.AuthorId and count(BookId)>1
• select AuthorName from Authors, Books where Authors.AuthorId=Books.AuthorId group by AuthorName having count(*)>1
• select AuthorName from Authors where AuthorId in (select AuthorId from Books having count(BookId)>1)
86. Which of the following statements are false?
Answers:
• trim() function is used to remove leading and trailing spaces from a string
• ltrim() function is used to remove leading spaces from a string
• rtrim() function is used to remove trailing spaces from a string
• alltrim() function is used to remove leading and trailing spaces from a string
87. Consider the following transaction code:
Begin Transaction
Update names_table set employee_name = "Ramesh" where employee_name = "Mahesh"
Save Transaction SAVE_POINT
Update salaries set salary=salary + 900 where employee_job = "Engineer"
Rollback transaction
Commit transaction
What will be the result produced by this transaction?
Answers:
• "Ramesh" will be updated to "Mahesh", but salaries of engineers will not be updated.
• Neither "Ramesh" will be updated to "Mahesh", nor the salary of engineers will be updated.
• "Ramesh" will be updated to "Mahesh" and salary of engineers will also be updated.
• "Mahesh" will be updated to "Ramesh", but salaries of engineers will not be updated.
No comments:
Post a Comment