0% found this document useful (0 votes)
352 views

SQL Quries

Exam 70-433 Preparation: Microsoft SQL Server Database Development Questions. In a department store, employees are in charge of adding the records to tables. James would like the DatabaseOperations table to receive a new record. How can He create a trigger to perform that operation?

Uploaded by

Karimulla Kolimi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
352 views

SQL Quries

Exam 70-433 Preparation: Microsoft SQL Server Database Development Questions. In a department store, employees are in charge of adding the records to tables. James would like the DatabaseOperations table to receive a new record. How can He create a trigger to perform that operation?

Uploaded by

Karimulla Kolimi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 132

Exam 70-433 Preparation: Microsoft SQL Server Database Development

Questions
1. James is working for a department store. He has created two tables as follows: 2. CREATE TABLE Inventory.Categories 3. ( 4. CategoryID int identity(1, 1) primary key, 5. Category nvarchar(20) not null 6. ); 7. GO 8. CREATE TABLE Inventory.StoreItems 9. ( 10. ItemNumber nvarchar(10) primary key, 11. CategoryID int foreign key 12. references Inventory.Categories(CategoryID), 13. ItemName nvarchar(60) not null, 14. Size nvarchar(20), 15. UnitPrice money 16. ); 17. GO 18. 19. INSERT INTO Inventory.Categories(Category) 20. VALUES(N'Men'), (N'Women'), (N'Boys'), (N'Girls'),(N'Miscellaneous'); GO The employees of the company are in charge of adding the records to the tables. To keep track of the records added to the StoreItems table, James creates a table as follows: CREATE TABLE Inventory.DatabaseOperations ( OperationID int identity(1,1) NOT NULL, ObjectType nchar(20) default N'Table', ObjectName nvarchar(40), PerformedBy nvarchar(50), ActionPerformed nvarchar(max), TimePerformed datetime, CONSTRAINT PK_Operations PRIMARY KEY(OperationID) ); GO When a new item is added to the StoreItems table, James would like the DatabaseOperations table to receive a new record to that effect. How can James create a trigger to perform that operation? a. CREATE TRIGGER Inventory.NewProductCreated b. ON Inventory.StoreItems c. AFTER INSERT d. AS e. BEGIN f. INSERT INTO Inventory.DatabaseOperations(ObjectType, g. ObjectName, PerformedBy, h. ActionPerformed, TimePerformed) i. VALUES(DEFAULT, N'StoreItems', SUSER_SNAME(), j. N'New product added', GETDATE())

k. END l. GO m. CREATE TRIGGER Inventory.NewProductCreated n. AFTER INSERT o. FOR OBJECT::Inventory.StoreItems p. AS q. BEGIN r. INSERT INTO Inventory.DatabaseOperations(ObjectType, s. ObjectName, PerformedBy, t. ActionPerformed, TimePerformed) u. VALUES(DEFAULT, N'StoreItems', SUSER_SNAME(), v. N'New product added', GETDATE()) w. END x. GO y. CREATE OBJECT::Inventory.NewProductCreated z. ON Inventory.StoreItems aa. AS TRIGGER FOR INSERT bb. BEGIN cc. RETURN dd. INSERT INTO Inventory.DatabaseOperations(ObjectType, ee. ObjectName, PerformedBy, ff. ActionPerformed, TimePerformed) gg. VALUES(DEFAULT, N'StoreItems', SUSER_SNAME(), hh. N'New product added', GETDATE()); ii. END jj. GO kk. CREATE TRIGGER Inventory.NewProductCreated ll. ON Inventory.StoreItems mm. SET TRIGGER = INSERT nn. AS oo. RETURN pp. INSERT INTO Inventory.DatabaseOperations(ObjectType, qq. ObjectName, PerformedBy, rr. ActionPerformed, TimePerformed) ss. VALUES(DEFAULT, N'StoreItems', SUSER_SNAME(), tt. N'New product added', GETDATE()); uu. GO vv. CREATE TRIGGER Inventory.NewProductCreated ww. ON Inventory.StoreItems xx. FOR INSERT yy. AS zz. INSERT INTO Inventory.DatabaseOperations(ObjectType, aaa. ObjectName, PerformedBy, bbb. ActionPerformed, TimePerformed) ccc. VALUES(DEFAULT, N'StoreItems', SUSER_SNAME(), ddd. N'New product added', GETDATE()); eee. GO 21. Dave has a table named Products and that has a few records. The table was created as follows: 22. CREATE TABLE Products 23. ( 24. ProductID int identity(1, 1) not null, 25. DateAcquired date, 26. Name nvarchar(50), 27. Size nvarchar(32),

28. UnitPrice money, 29. DiscountRate decimal(4, 2), 30. CONSTRAINT PK_Products PRIMARY KEY(ProductID) 31. ); GO He wants to get a list of products using their names, their sizes, and prices. He wants the list to be sorted by the acquired dates but he does not want to see the acquired date column. What code can he use to do that? a. SELECT DateAcquired, Name, Size, UnitPrice b. FROM Products c. ORDER BY DateAcquired d. SET DateAcquired = NULL; e. GO f. SELECT DateAcquired, Name, Size, UnitPrice g. FROM Products h. HIDE DateAcquired i. ORDER BY DateAcquired; j. GO k. SELECT Name, Size, UnitPrice l. FROM Products m. ORDER BY DateAcquired; n. GO o. SELECT Name, Size, UnitPrice p. ORDER BY DateAcquired q. FROM Products r. SET DateAcquired SHOW = OFF; s. GO t. SELECT DateAcquired, Name, Size, UnitPrice u. SORT(DateAcquired) IS NULL v. FROM Products; w. GO 32. Andrew has been using a table of products that was created as follows: 33. CREATE TABLE Products 34. ( 35. ProductID int identity(1, 1), 36. Name nvarchar(50), 37. UnitPrice money 38. ); GO The table already has a few records that were added previously. This morning, to add a few records, Andrew writes the following code: INSERT Products(Name, UnitPrice) VALUES(N'Mid Lady Bag - Lizard', 228), (N'Holly Gladiator Heel Shoes', 198), (N'Short Black Skirt', 55.85); GO When he executes that code, Andrew receives the following error: Explicit value must be specified for identity column in table 'Products' either when IDENTITY_INSERT is set to ON or when a replication user is inserting into a NOT FOR REPLICATION identity column. What must Andrew do to let the database engine generate a product number? a. He must first execute the sp_autogenerate stored procedure b. He must include the list of column in the INSERT statement, as in

c. INSERT Products(ProductID, Name, UnitPrice) d. VALUES(N'Mid Lady Bag - Lizard', 228), e. (N'Holly Gladiator Heel Shoes', 198), f. (N'Short Black Skirt', 55.85); GO g. She must first use a SELECT statement that calls the MAX(ProductID) aggregate function to get the highest number that the ProductID column holds. Then increment it by 1 when adding a new record h. He must set IDENTITY_INSERT to OFF i. He must set AUTOINCREMENT to FALSE

39. Steve inherited a table named Customers and that was created as follows: 40. CREATE TABLE Customers 41. ( 42. AccountNumber nchar(7), 43. FirstName nvarchar(20), 44. LastName nvarchar(20), 45. PhoneNumber nvarchar(20), 46. EmailAddress nvarchar(40) ); Now he wants an index tied to that table. What code can he use to create the index? a. CREATE INDEX IDX_Customers ON Customers SET IDX_Customers = AccountNumber; b. CREATE INDEX IDX_Customers AS AccountNumber FROM Customers; c. CREATE INDEX IDX_Customers ON Customers(AccountNumber); d. SELECT AccountNumber FROM Customers CREATE INDEX IDX_Customers; e. EXEC CREATE INDEX ON Customers(AccountNumber) = IDX_Customers; 47. Ashley receives instructions to create a table of customers with the following recommendations:     The table will be named Customers The table must have a column that includes a primary key that uses natural numbers starting at 1000 and automacally incrementing by 1 The table must have a column for the customer's name The table must have a column for the customer's phone number

In what three ways can Ashley create the table? e. CREATE TABLE Customers f. ( g. CustomerID INT IDENTITY(1000, 1), h. Name nvarchar(50), i. [Phone Number] nvarchar(20), j. CREATE PRIMARY KEY WITH CustomerID k. ); l. GO m. CREATE TABLE Customers n. ( o. CustomerID INT IDENTITY(1000, 1) p. CONSTRAINT PK_Customers PRIMARY KEY(CustomerID), q. Name nvarchar(50), r. [Phone Number] nvarchar(20), s. ); t. GO

u. CREATE TABLE Customers v. ( w. CustomerID INT IDENTITY(1000, 1) PRIMARY KEY, x. Name nvarchar(50), y. [Phone Number] nvarchar(20), z. ); aa. GO bb. CREATE TABLE Customers cc. ( dd. CustomerID INT IDENTITY(1000, 1), ee. Name nvarchar(50), ff. [Phone Number] nvarchar(20), gg. PRIMARY KEY REFERENCES(CustomerID) hh. ii. ); jj. GO kk. CREATE TABLE Customers ll. ( mm. CustomerID INT IDENTITY(1000, 1), nn. Name nvarchar(50), oo. [Phone Number] nvarchar(20), pp. CONSTRAINT PK_Customers PRIMARY KEY(CustomerID) qq. ); rr. GO Hank has the following table of employees: CREATE TABLE Personnel.Employees ( EmployeeNumber nchar(7) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), EmploymentStatus smallint, HourlySalary money ); GO INSERT Personnel.Employees VALUES(N'284-680', N'Anselme', N'Bongos', 2, 18.62), (N'730-704', N'June', N'Malea', 1, 9.95), (N'735-407', N'Frank', N'Monson', 3, 14.58), (N'281-730', N'Jerry', N'Beaulieu', 1, 16.65); GO Hank also has the following table of sales made by employees during a certain period: CREATE TABLE Commercial.Sales ( SaleID int identity(1, 1), EmployeeNumber nchar(7) not null, SaleDate date, Amount money ); GO INSERT INTO Commercial.Sales(EmployeeNumber, SaleDate, Amount) VALUES(N'284-680', N'2011-02-14', 4250), (N'735-407', N'2011-02-14', 5300), (N'730-704', N'2011-02-14', 2880), (N'281-730', N'2011-02-14', 4640),

(N'284-680', N'2011-02-15', 4250), (N'281-730', N'2011-02-15', 3675); GO Now, Hank wants to get a list that displays the name of each employee and the number of sales he or she made. What code can he use? . SELECT LastName + N', ' + FirstName Employee, a. COUNT(EmployeeNumber) AS [Number of Sales] b. FROM Commercial.Sales cs JOIN c. Personnel.Employees pe ON d. cs.EmployeeNumber = pe.EmployeeNumber e. GROUP BY LastName + N', ' + FirstName f. SELECT LastName + N', ' + FirstName Employee, g. COUNT(Amount) AS [Number of Sales] h. FROM Commercial.Sales cs JOIN i. Personnel.Employees pe ON j. cs.EmployeeNumber = pe.EmployeeNumber k. GROUP BY LastName + N', ' + FirstName l. SELECT LastName + N', ' + FirstName Employee, m. COUNT(*) AS [Number of Sales] n. GROUP BY LastName + N', ' + FirstName o. FROM Commercial.Sales cs JOIN p. Personnel.Employees pe ON q. cs.EmployeeNumber = pe.EmployeeNumber r. SELECT LastName + N', ' + FirstName Employee, s. COUNT(*) AS [Number of Sales] t. FROM Commercial.Sales cs JOIN u. Personnel.Employees pe ON v. cs.EmployeeNumber = pe.EmployeeNumber w. GROUP BY LastName + N', ' + FirstName x. HAVING Amount NOT NULL y. SELECT LastName + N', ' + FirstName Employee, z. COUNT(*) AS [Number of Sales] aa. FROM Commercial.Sales cs JOIN bb. Personnel.Employees pe ON cc. cs.EmployeeNumber = pe.EmployeeNumber dd. GROUP BY LastName + N', ' + FirstName ee. WHERE Amount IS NOT NULL Mark has a table named Employees created in a schema named Personnel as follows: CREATE TABLE Personnel.Employees ( EmployeeNumber nchar(10) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), EmploymentStatus tinyint, HourlySalary money ); GO INSERT Personnel.Employees VALUES(N'284-680', N'Anselme', N'Bongos', 2, 18.62), (N'730-704', N'June', N'Malea', 1, 9.95); GO To protect the table, Mark wants to create a view used for data entry. The view will be named NewHire. The view must include a condition that states that the staus of the new employee can be 1, 2, or 3 and no other number. Mark wants to make sure

no record is added to the table if that record violates the condition in the view. What code can he use to accomplish that? . CREATE VIEW Personnel.NewHire a. WITH CHECK OPTION b. AS c. SELECT EmployeeNumber, d. FirstName, e. LastName, f. EmploymentStatus, g. HourlySalary h. FROM Personnel.Employees i. WHERE EmploymentStatus IN(1, 2, 3); -- Full Time, Part Time, Unknown/Other j. GO k. CREATE VIEW Personnel.NewHire l. AS m. WITH CHECK OPTION n. SELECT EmployeeNumber, o. FirstName, p. LastName, q. EmploymentStatus, r. HourlySalary s. FROM Personnel.Employees t. WHERE EmploymentStatus IN(1, 2, 3); -- Full Time, Part Time, Unknown/Other u. GO v. CREATE VIEW Personnel.NewHire w. SET CHECK OPTION ON x. AS y. SELECT EmployeeNumber, z. FirstName, aa. LastName, bb. EmploymentStatus, cc. HourlySalary dd. FROM Personnel.Employees ee. WHERE EmploymentStatus IN(1, 2, 3); -- Full Time, Part Time, Unknown/Other ff. GO gg. CREATE VIEW Personnel.NewHire hh. AS ii. SELECT EmployeeNumber, jj. FirstName, kk. LastName, ll. EmploymentStatus, mm. HourlySalary nn. FROM Personnel.Employees oo. WHERE EmploymentStatus IN(1, 2, 3) -- Full Time, Part Time, Unknown/Other pp. WITH CHECK OPTION; qq. GO rr. CREATE VIEW Personnel.NewHire ss. AS tt. SELECT EmployeeNumber, uu. FirstName, vv. LastName, ww. EmploymentStatus, xx. HourlySalary

yy. FROM Personnel.Employees zz. CONSTRAINT CHECK EmploymentStatus IN(1, 2, 3); -- Full Time, Part Time, Unknown/Other aaa. GO What is wrong with the following code? CREATE TABLE Employees ( EmployeeNumber nchar(60) not null unique primary key, [Full Name] nvarchar(50), HourlySalary money, Department nchar(4) ) . Nothing

a. The nchar data type has a limit length of 12 character but the code indicates 60. Consequently, this code will produce an error b. UNIQUE and PRIMARY KEY cannot be combined in the definition of a column c. The name of a column cannot have a space d. The code should end with a semi-colon Imagine you have the following table: CREATE TABLE Employees ( EmployeeNumber nchar(10) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), DepartmentCode nchar(6), HourlySalary money ); GO Then you create the following view: CREATE VIEW EmployeesRecords AS SELECT EmployeeNumber, FirstName, LastName FROM Employees; GO Now you want to modify the view to add the HourlySalary field. What code would you use to do that? . UPDATE VIEW EmployeesRecords a. BEGIN b. SELECT EmployeeNumber, FirstName, LastName, HourlySalary c. FROM Employees; d. END e. ALTER VIEW EmployeesRecords f. AS g. SELECT EmployeeNumber, FirstName, LastName, HourlySalary h. FROM Employees; i. GO j. EXECUTE sp_change EmployeesRecords k. BEGIN l. SELECT EmployeeNumber, FirstName, LastName, HourlySalary m. FROM Employees; n. END

o. p. q. r. s. t. u. v. w.

ALTER VIEW EmployeesRecords AS ADD HourlySalary FROM Employees; END ALTER VIEW EmployeesRecords AS ADD Employees.HourlySalary; GO

Daniel has the following table in his organization: CREATE TABLE Members ( MemberID int unique, Name nvarchar(50), MembershipStatus nvarchar(20) CHECK(MembershipStatus IN (N'In Review', N'Active', N'Suspended')) ); INSERT INTO Members VALUES(100, N'Albert Welch', N'Active'), (104, N'Daniel Simpson', N'Suspended'), (264, N'Ann Plants', N'Active'), (275, N'Jane Womack', N'In Review'), (279, N'June Palau', N'Suspended'), (288, N'Paul Motto', N'Active'); GO He wants to remove all members who have been suspended from the organization. What code can he use? . DELETE ALL * FROM Members a. WHERE MembershipStatus IS N'Suspended'; b. GO c. DELETE FROM Members d. WHERE MembershipStatus != N'Suspended'; e. GO f. REMOVE Members g. WHERE MembershipStatus = N'Suspended'; h. GO i. EXECUTE sp_remove FROM Members j. WHERE MembershipStatus = N'Suspended'; k. GO l. DELETE FROM Members m. WHERE MembershipStatus = N'Suspended'; n. GO Jane has the following tables and their records: CREATE TABLE Departments ( DepartmentCode nchar(6) not null primary key, DepartmentName nvarchar(50) not null ); GO INSERT INTO Departments VALUES(N'HMRS', N'Human Resources'), (N'ACNT', N'Accounting'),

(N'PSNL', N'Personnel'), (N'RSDV', N'Research & Development'); GO CREATE TABLE Employees ( EmployeeNumber nchar(10) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), DepartmentCode nchar(6) ); GO INSERT INTO Employees VALUES(N'283-947', N'Timothy', N'White', N'RSDV'), (N'572-384', N'Jeannette', N'Welch', N'PSNL'), (N'279-242', N'Ann', N'Welch', N'HMRS'), (N'495-728', N'Robert', N'Simms', N'RSDV'), (N'382-505', N'Paula', N'Waters', N'PSNL'), (N'268-046', N'Martine', N'Nyamoto', N'ACNT'), (N'773-148', N'James', N'Larsen', N'RSDV'), (N'958-057', N'Peter', N'Aut', N'HMRS'); GO She wants to change the department of employees from the personnel department to the human resources department. When the operation has been performed, she wants to see the list of records that were affected. What code can she use? . UPDATE Employees a. SET DepartmentCode = N'PSNL' b. OUTPUT INSERTED.* c. WHERE DepartmentCode = N'HMRS'; d. GO e. UPDATE Employees f. SET DepartmentCode = N'HMRS' g. OUTPUT INSERTED.* h. WHERE DepartmentCode = N'PSNL'; i. GO j. UPDATE Employees k. SET DepartmentCode = N'PSNL' l. WHERE DepartmentCode = N'HMRS' m. OUTPUT DELETED.*; n. GO o. SET Employees p. OUTPUT UPDATED.* q. UPDATE DepartmentCode = N'HMRS' r. WHERE DepartmentCode = N'PSNL'; s. GO t. SET Employees u. UPDATE DepartmentCode = N'PSNL' v. WHERE DepartmentCode = N'HMRS' w. OUTPUT INSERTED.*; x. GO Consider the following table: CREATE TABLE StoreItems ( ItemNumber int, ItemName nvarchar(60), ItemDescription nvarchar(max),

UnitPrice money ); GO What two segment codes can be used to create three records (select 2)? . a. b. c. d. e. f. g. h. i. j. k. l. m. n. o. p. q. r. s. t. INSERT StoreItems VALUES(190857, N'Men Deodorant', 5.05); INSERT INTO StoreItems VALUES(838273, N'Currently on sale bar soaps', N'Sold as 6 bars', 1.95); INSERT StoreItems(ItemNumber, ItemName, ItemDescription) VALUES(828305, N'Cereal in a Jar', N''); INSERT StoreItems VALUES(149752, N'Chocolate Bar', NULL, 75.00); INSERT INTO StoreItems(ItemNumber, ItemName, UnitPrice) VALUES(350882, N'1Gal Milk 2%', 3.85); INSERT StoreItems VALUES(247014, N'Peanut Butter Jar', N'Sold in 24 Units', 2.55); INSERT StoreItems VALUES(197084, N'Tomato Juice', 4.55), (274859, N'Orange Juice', 8.95), (927304, N'2-Litter Soda Bottle', 2.25); INSERT StoreItems(ItemNumber, ItemName, UnitPrice) VALUES(918839, N'Ground Beef', 6.55), (829307, N'Tomato Sauce', 2.95); INSERT StoreItems(ItemNumber, ItemName, ItemDescription) VALUES(941155, N'12-Doughnuts Pack', N'On sale - must go');

You wrote code as follows to give the appropriate permission(s) to Jeremy Andrew Blasick (username: jblasick) to be able to change records on the Employees table: CREATE DATABASE NationalBank; GO USE NationalBank; GO CREATE TABLE Employees ( EmployeeNumber int, FirstName nvarchar(20), LastName nvarchar(20), Salary decimal(20, 6) ); GO CREATE USER [Jeremy Blasick] FOR LOGIN jblasick; GO GRANT UPDATE ON OBJECT::Employees TO [Jeremy Blasick]; GO INSERT INTO Employees VALUES(500727, N'John', N'Harrolds', 18.25);

GO So you call Jeremy and ask him to change the record in the Employees table. After a few minutes, he calls you back saying he can't and he doesn't understand why. What do you think is the problem? . In your code, the INSERT INTO code should have been written before the CREATE USER code

a. The table doesn't have a primary key and therefore cannot allow record change b. The permission(s) given to the user are not enough c. You should have revoked the UPDATE permission before granting it because granting the UPDATE permission automatically invokes the INSERT permission d. In the CREATE USER statement, you must use either his actual username or his full name, including his middle name You had already created a user as Kirk Blankey. He has been asked to manage the Students table. He must be able to create and change records. He also must be able to give manage the rights of other users on the database. What code can you write to give him the appropriate rights? . a. b. c. d. e. f. g. h. i. j. k. l. m. n. o. p. q. r. s. t. u. v. GRANT INSERT, UPDATE, SELECT TO [Kirk Blankey] ON OBJECT::Students; GO GRANT CONNECT, INSERT, UPDATE, ON OBJECT::Students TO User = N'Kirk Blankey' WITH GRANT OPTION; GO GRANT INSERT, UPDATE, SELECT ON OBJECT::Students TO [Kirk Blankey] WITH GRANT OPTION; GO GRANT OPTION = ALL TO [Kirk Blankey] ON OBJECT::Students; GO GRANT ALTER, CONNECT ON OBJECT::Students TO [Kirk Blankey] WITH OPTION GRANT ALL; GO

Consider the following statement from the State University database: USE StateUniversity1; GO SELECT TeacherID, FullName, Teachers.CourseID FROM Teachers; GO

What will this statement produce? . Nothing, because Teachers.CourseID will create an error

a. It will show the list of teachers and their TeacherID but excluding the CourseID b. It will show the list of teachers, including their TeacherID, their names, and their CourseID c. An error because it doesn't specify what the primary key of the table is d. It will show the list of teachers that includes only CourseID while excluding the TeacherID and the full name Consider the following table of records TeacherID TeacherName 218440 250077 270480 274692 294057 493748 948025 972837 Roberta Jerseys Mary Shamberg Olympia Sumners Leslie Aronson Peter Sonnens John Franks Chryssa Lurie Hellah Zanogh CourseCode CMST 385 CMIS 101 CMIS 320 CMIS 170 CMST 306 CMIS 101 CMIS 320 CMST 306

What statements would produce appropriate results (select 3)? . a. b. c. d. e. f. g. h. i. j. k. l. m. n. SELECT * FROM Teachers WHERE CourseID = [CMST 320]; GO SELECT TeacherID, TeacherName, CourseID FROM Teachers; GO SELECT * FROM Teachers WHEN CourseID = N'CMIS 101'; GO SELECT TeacherName FROM Teachers WHERE TeacherName = N'Leslie Aronson'; GO SELECT * FROM Teachers WHERE CourseID = N'CMIS 101'; GO

Consider the following statement from the State University database: SELECT CourseID, COUNT(*) FROM Teachers GROUP BY CourseID; GO What will this statement produce?

An error: CourseID should have been written Teachers.CourseID

a. The list of teachers and the course(s) they teach b. The list of teachers, excluding the course(s) they teach c. The list of courses and the number of teachers associated with that course d. An error because the statement left out the other columns of the table Consider the following tables: Table Name: Courses CourseID CourseName CMIS 101 Introduction to Problem Solving and Algorithm Design Credits 3 3 3 3 3 3

CMIS 170 Introduction to XML CMIS 320 Relational Databases CMIS 420 Advanced Relational Databases CMST 306 Introduction to Visual Basic Programming CMST 385 Internet and Web Design Table Name: Teachers TeacherID 218440 250077 270480 274692 294057 493748 948025 972837 FullName Roberta Jerseys Mary Shamberg Olympia Sumners Leslie Aronson Peter Sonnens John Franks Chryssa Lurie Hellah Zanogh

Table Name: TeachersAndCourses CourseID 1 2 3 4 5 6 CourseName 493748 270480 294057 274692 274692 972837 Credits CMIS 101 CMIS 328 CMST 306 CMIS 170 CMIS 101 CMIS 320

7 8 9 10 11 12 13

250077 294057 294057 948025 972837 270480 218440

CMIS 101 CMST 309 CMST 412 CMIS 320 CMST 306 CMIS 320 CMST 385

What statements would produce appropriate results (select 2)? . a. b. c. d. e. f. g. h. i. j. k. l. m. n. o. p. q. r. s. SELECT TeacherID, CourseID FROM TeachersAndCourses GROUP BY CourseID; GO SELECT * FROM TeachersAndCourses WHERE CourseID = N'CMIS 328' GROUP BY CourseID; GO SELECT CourseID, COUNT(*) FROM TeachersAndCourses GROUP BY CourseID; GO SELECT TeacherID, COUNT(*) FROM TeachersAndCourses GROUP BY TeacherID; GO SELECT TeacherID, COUNT(*) FROM TeachersAndCourses GROUP BY CourseID; GO

Consider the following two tables: CREATE TABLE EmploymentTypes ( EmplTypeID int not null, EmplType nvarchar(20) ); GO CREATE TABLE Employees ( EmployeeNumber nchar(7) not null, EmplTypeID int, FirstName nvarchar(20), LastName nvarchar(20), HourlySalary money ); GO INSERT INTO EmploymentTypes(EmplTypeID, EmplType) VALUES(10, N'Employee'), (20, N'Contractor'), (40, N'Seasonal'), (60, N'Other'); GO

INSERT INTO Employees(EmployeeNumber, EmplTypeID, FirstName, LastName, HourlySalary) VALUES(N'202-725', 20, N'Julie', N'Flanell', 36.55), (N'927-205', 10, N'Paulette', N'Simms', 26.65), (N'840-202', 40, N'Alexandra', N'Ulm', 12.85), (N'472-095', 10, N'Ellie', N'Tchenko', 11.95), (N'268-046', 60, N'Martine', N'Nyamoto', 15.52), (N'273-148', 20, N'James', N'Larsen', 18.24), (N'481-729', 10, N'Faye', N'Cross', 14.92); GO What will the following code produce? SELECT EmplTypeID FROM Employees WHERE HourlySalary < ALL(SELECT AVG(HourlySalary) FROM Employees GROUP BY EmplTypeID); GO . The employment type ID of the staff member who has the highest salary

a. The names of all staff members who have the highest salaries per employment type b. The name of the staff member who has the highest salary in each type of employment c. The highest salary in each type of employment d. The salary of the staff member with the highest hourly salary Your boss created a database named SuperMarket1 for a new client. He wants you to create a new table for the employees and to let Hermine Nkolo (Login Name: hnkolo) manage that table. To make it happen, you write the following script: CREATE SCHEMA Personnel; GO CREATE TABLE Personnel.Employees ( EmplNbr nchar(10), FirstName nvarchar(20), LastName nvarchar(20), Salary money, FullTime bit ); GO INSERT INTO Personnel.Employees VALUES(N'29730', N'Philippe', N'Addy', 20.05, 1), (N'28084', N'Joan', N'Shepherd', 12.72, 0), (N'79272', N'Joshua', N'Anderson', 18.26, 0), (N'22803', N'Gregory', N'Swanson', 15.95, 0), (N'83084', N'Josephine', N'Anderson', 22.25, 1); GO CREATE USER Hermine FOR LOGIN hnkolo; GO GRANT INSERT ON OBJECT::Personnel.Employees TO Hermine; GO

GRANT UPDATE ON OBJECT::Personnel.Employees TO Hermine; GO After executing the script, you let Hermine know that she can use the table. After a few minutes, Hermine calls you and says that when she tries to create records, she receives an error that she was denied the object:

How would you solve the problem: . It appears that Hermine doesn't have the CONNECT permission. Therefore, grant the CONNECT permission to Hermine

a. In the SQL Server Management Studio, open the properties of the Employees table and change the User name from Hermine to hrnkolo b. Grant the SELECT permission c. Your account probably does not have the WITH GRANT permission d. The table was marked as read-only Pamela McDugan wrote the following statement to create a view: CREATE VIEW Personnel.Contractors AS SELECT empl.EmployeeNumber, empl.[First Name], empl.[Last Name] FROM Personnel.Employees empl ORDER BY empl.[Last Name] GO When she executes the statement to create the view, she receives an error. What is wrong? . You cannot include an ORDER BY clause in this view

a. The error is because empl is not in square brackets but the names of columns are b. The names of columns must not contain space c. The ORDER BY clause must be written before the FROM expression d. The name of the view must not be preceded by Personnel. In can only be preceded by the name of the database

Michael wants to test something on a view. So he writes the following code to create a temporary table and a view: CREATE TABLE #Employees ( EmployeeNumber nchar(10) not null, [First Name] nvarchar(20), [Last Name] nvarchar(20) not null, Title nvarchar(40), Salary money ); GO CREATE VIEW Contractors AS SELECT EmployeeNumber, [First Name], [Last Name] FROM #Employees; GO When he executes the code, she receives an error. What do you think is the problem? . You cannot create a view for a temporary table

a. The name of the view must be preceded by # b. The names of columns must not contain space c. The name of the table in the view definition must not start with # d. In order to create a view from a temporary table, the table must have a primary key Consider the tables from the State University database. Imagine you want to get a list of all teachers whether they have a matching CourseID in the Courses table or not. What statement would produce that result? . a. b. c. d. e. f. g. h. i. j. k. l. m. n. o. p. q. r. SELECT TeacherID, FullName, Teachers.CourseID FROM Teachers LEFT OUTER JOIN Courses ON Teachers.CourseID = Courses.CourseID; GO SELECT TeacherID, FullName, Teachers.CourseID FROM Teachers CROSS OUTER JOIN Courses ON Teachers.CourseID = Courses.CourseID; GO SELECT TeacherID, FullName, Teachers.CourseID FROM Teachers SELECT Courses.CourseID, Courses.CourseName FROM Courses LEFT OUTER JOIN Teachers ON Teachers.CourseID = Courses.CourseID; GO SELECT TeacherID, FullName, Teachers.CourseID FROM Teachers CROSS JOIN Courses

Consider the following tables: CREATE TABLE Departments (

DepartmentCode nchar(6) not null primary key, DepartmentName nvarchar(50) not null ); GO CREATE TABLE Employees ( EmployeeNumber nchar(10) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), DepartmentCode nchar(6) ); GO What would the following statement produce? SELECT Employees.EmployeeNumber, Employees.FirstName, Employees.LastName, Departments.DepartmentName FROM Employees INNER JOIN Departments ON Departments.DepartmentCode = Employees.DepartmentCode; GO . The list of all employees and the department each employee belongs to

a. The list of each employee associated with each department (not just the department the employee actually belongs to) b. Nothing, because the Employees table does not specify a foreign key c. An error, because the SELECT statement should start with the Departments table d. The list of departments and all employees Consider the following tables: CREATE TABLE Departments ( DepartmentCode nchar(6) not null primary key, DepartmentName nvarchar(50) not null ); GO CREATE TABLE Employees ( EmployeeNumber nchar(10) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), DepartmentCode nchar(6) ); GO What is the difference in result between this code: SELECT Employees.EmployeeNumber, Employees.FirstName,

Employees.LastName, Departments.DepartmentName FROM Employees INNER JOIN Departments ON Departments.DepartmentCode = Employees.DepartmentCode; GO and this one? SELECT Employees.EmployeeNumber, Employees.FirstName, Employees.LastName, Departments.DepartmentName FROM Employees JOIN Departments ON Departments.DepartmentCode = Employees.DepartmentCode; GO . The first code would show the list of each employee associated with each department. The second code would produce an error

a. No difference: both would produce the same result b. The first code would produce an error. The second code would show each department associated with each employee c. Both codes would produce errors because the assignment is ill-formed d. The first code will show the list of each employee and the department he or she belongs to. The second code will show each department with each employee of the company, even if the employee doesn't belong to the department Consider the following tables: CREATE TABLE Departments ( DepartmentCode nchar(6) not null primary key, DepartmentName nvarchar(50) not null ); GO INSERT INTO Departments VALUES(N'HMRS', N'Human Resources'), (N'ACNT', N'Accounting'), (N'RSDV', N'Research & Development'); GO CREATE TABLE Employees ( EmployeeNumber nchar(10) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), DepartmentCode nchar(6) ); GO INSERT INTO Employees VALUES(N'283-947', N'Timothy', N'White', N'RSDV'), (N'495-728', N'Robert', N'Simms', N'RSDV'), (N'268-046', N'Martine', N'Nyamoto', N'ACNT'), (N'273-148', N'James', N'Larsen', N'RSDV'), (N'958-057', N'Peter', N'Aut', N'HMRS');

GO What would the following code produce? SELECT Employees.EmployeeNumber, Employees.FirstName, Employees.LastName, Departments.DepartmentName FROM Personnel.Employees JOIN Departments ON Departments.DepartmentCode = Employees.DepartmentCode WHERE Departments.DepartmentCode = N'RSDV'; GO . An error, because the WHERE clause must be written before the FROM clause

a. An error because the Departments.DepartmentCode field is not specified in the SELECT statement b. A list of employees who belong to the Research & Development department c. A list of departments that are joined to the employees d. A list that contains each department and all employees, start with those that belong to the department that has RSDV as code Maggie is in charge of managing an old table from an existing database. Now she wants to delete the table but is worried about the consequences and calls you to get your input. What type of answer would you present her? . You can't delete a view once it has been created and executed at least once

a. Delete the table or tables that hold(s) the records of the view b. Delete the schema first c. Check the records first and copy them to a temporary table d. Check the permissions first and find out how they are used on the view Gary wants to monitor the transactions in a bank database. So he wrote code as follows: CREATE SCHEMA Management; GO CREATE SCHEMA Personnel; GO CREATE SCHEMA Transactions; GO GOCREATE TABLE Transactions.Customers ( CustomerID int Identity(1, 1) NOT NULL, DateCreated date, AccountNumber nvarchar(20), CustomerName nvarchar(50) ); GO CREATE TABLE Transactions.DatabaseOperations ( OperationID int identity(1,1) NOT NULL, ObjectName nvarchar(40), PerformedBy nvarchar(50), ActionPerformed nvarchar(50), CONSTRAINT PK_DBOperations PRIMARY KEY(OperationID)

); GO CREATE TRIGGER Personnel.ForCustomers ON Transactions.Customers AFTER INSERT AS BEGIN INSERT INTO Management.DatabaseOperations(ObjectName, PerformedBy, ActionPerformed) VALUES(N'Customers', SUSER_SNAME(), N'Processed a deposit') END GO Frank executes that code and it works fine. To test the database, Gary writes the following code to add a new record to the Customers table: INSERT INTO Transactions.Customers(DateCreated, AccountNumber, CustomerName) VALUES(N'02/20/2011', N'000-2860-3982', N'John Doe'); GO When he executes it, Gary receives an error. What do you think is the problem? . Triggers don't need a schema

a. Since neither a user nor a login was created in the code, it appears that Frank doesn't have the right permissions to the trigger b. In the code for the trigger, Frank must specify the schema of the Customers table as Management (as in Management.Customers) c. Both the Customers table and the ForCustomers triger must use the same schema d. The DatabaseOperations table called in the trigger must not have a primary key constraint Martha inherited the following table and its records CREATE SCHEMA Listing; GO CREATE TABLE Listing.Apartments ( UnitNumber int not null, Bedrooms int, Bathrooms real, Price money, Deposit money, Available bit ); GO INSERT Listing.Apartments VALUES(104, 2, 1.00, 1050.00, 300.00, (306, 3, 2.00, 1350.00, 425.00, (105, 1, 1.00, 885.00, 250.00, (202, 1, 1.00, 950.00, 325.00, (304, 2, 2.00, 1250.00, 300.00, (106, 3, 2.00, 1350.00, 425.00, (308, 0, 1.00, 875.00, 225.00, (203, 1, 1.00, 885.00, 250.00,

0), 1), 1), 0), 0), 1), 1), 1),

(204, 2, 2.00, 1125.00, 425.00, 1), (205, 1, 1.00, 1055.00, 350.00, 0); GO The documentation of the database indicates that the first symbol of a unit number indicates the floor level. What two codes would let Martha see the list of apartments from the second floor? . SELECT * a. FROM Units b. WHERE UnitNumber IN N'200' UP; c. GO d. SELECT ALL * e. FROM Units f. WHERE UnitNumber LIKE N'2%'; g. GO h. SELECT ALL * i. FROM Units j. WHERE UnitNumber FROM 200 TO 299; k. GO l. SELECT ALL * m. FROM Units n. WHERE UnitNumber BETWEEN N'200' AND N'300'; o. GO p. SELECT ALL * q. FROM UnitNumber r. FROM 200 TO 300; s. GO Ann has been asked to create a table of employees. The table must contain a column for hourly salaries and, during data entry, the table must reject any salary lower than 12.50. What code can she use to take care of this (Select Two)? . a. b. c. d. e. f. g. h. i. j. k. l. m. n. o. p. q. r. s. t. u. v. w. x. y. CREATE TABLE Employees ( EmployeeNumber nchar(60) not null, [Full Name] nvarchar(50), HourlySalary money CHECK(HourlySalary !< 12.50), Department nchar(4) ); GO CREATE TABLE Employees ( EmployeeNumber nchar(60) not null, [Full Name] nvarchar(50), HourlySalary money CONSTRAINT CHECK(HourlySalary >= 12.50), Department nchar(4) ); GO CREATE TABLE Employees ( EmployeeNumber nchar(60) not null, [Full Name] nvarchar(50), HourlySalary money, Department nchar(4), CONSTRAINT CK_HourlySalary CHECK (HourlySalary >= 12.50) ); GO CREATE TABLE Employees

z. ( aa. bb. cc. dd. ee. 12.50) ff. ); gg. GO hh. CREATE ii. ( jj. kk. ll. mm. nn. 12.50) oo. ); pp. GO

EmployeeNumber nchar(60) not null, [Full Name] nvarchar(50), HourlySalary money, Department nchar(4), CONSTRAINT CK_HourlySalary CHECK ON (HourlySalary >=

TABLE Employees EmployeeNumber nchar(60) not null, [Full Name] nvarchar(50), HourlySalary money, Department nchar(4), CONSTRAINT ON HourlySalary FOR CHECK(HourlySalary >=

Annouar has the following tables and their records: CREATE TABLE Departments ( Code nchar(4), Name nvarchar(40) ); GO CREATE TABLE Employees ( EmployeeNumber nchar(6) not null unique, [Full Name] nvarchar(50), HourlySalary money, Department nchar(4) ); GO INSERT Departments VALUES(N'HMNR', N'Human Resources'), (N'ACNT', N'Accounting'), (N'RNDV', N'Research & Development'); GO INSERT Employees VALUES(N'60-224', N'Frank Roberts', 20.15, N'RNDV'), (N'29-742', N'Marcial Engolo', 12.58, N'HMNR'), (N'82-073', N'John Duchant', 22.75, N'RNDV'), (N'82-503', N'Marthe Mengue', 15.86, N'ACNT'), (N'47-582', N'Hervey Arndt', 12.24, N'HMNR'), (N'82-263', N'Mark Edwards', 18.14, N'RNDV'); GO He is using the following code to get some statistics about the employees: SELECT MAX(HourlySalary) FROM Employees empls WHERE empls.Department = N'RNDV'; GO What will that code produce? . 20.15

a. 12.58 b. 22.75 c. 15.86 d. 18.14 Benjamin has the followng tables and their records: CREATE TABLE Departments ( Code nchar(4), Name nvarchar(40) ); GO CREATE TABLE Employees ( EmployeeNumber nchar(6) not null unique, [Full Name] nvarchar(50), Department nchar(4) ); GO INSERT Departments VALUES(N'HMNR', N'Human Resources'), (N'ACNT', N'Accounting'), (N'RNDV', N'Research & Development'); GO INSERT Employees VALUES(N'60-224', N'Frank Roberts', N'RNDV'), (N'29-742', N'Marcial Engolo', N'HMNR'), (N'82-073', N'John Duchant', N'RNDV'), (N'82-503', N'Marthe Mengue', N'ACNT'), (N'47-582', N'Hervey Arndt', N'HMNR'), (N'82-263', N'Mark Edwards', N'RNDV'); GO He wants to know the number of employees in the human resources department. Which one of the following codes can he use? . SELECT ALL COUNT(*) AS [# of Employees] FROM Employees empls a. WHERE empls.Department = N'HMNR'; b. GO c. SELECT ALL COUNT(*) FROM Employees empls AS [# of Employees] d. WHERE empls.Department = N'HMNR'; e. GO f. SELECT FROM Employees empls ALL COUNT(*) AS [# of Employees] g. WHERE empls.Department = N'HMNR'; h. GO i. SELECT COUNT(*) AS [# of Employees] j. WHERE empls.Department = N'HMNR' k. FROM Employees empls; l. GO m. SELECT WHERE empls.Department = N'HMNR' n. COUNT(*) AS [# of Employees] FROM Employees empls; o. GO Peter has the following table and its records: CREATE TABLE Employees (

EmployeeNumber nchar(6) not null unique, [Full Name] nvarchar(50), HourlySalary money ); GO INSERT Employees VALUES(N'60-224', N'Frank Roberts', 12.48), (N'29-742', N'Marcial Engolo', 30.15), (N'82-073', N'John Duchant', 8.75), (N'82-503', N'Marthe Mengue', 14.85), (N'47-582', N'Hervey Arndt', 10.06), (N'82-263', N'Mark Edwards', 25.55); GO He wants to get the highest salary. What code can he use? . SELECT FROM Employees empls MAX(HourlySalary) AS [Highest Salary]; a. GO b. SELECT FROM Employees empls HIGH(HourlySalary) AS [Highest Salary]; c. GO d. SELECT MAX(HourlySalary) AS [Highest Salary] FROM Employees empls; e. GO f. SELECT HIGH(HourlySalary) AS [Highest Salary] FROM Employees empls; g. GO h. SELECT MAX(HourlySalary) FROM Employees empls AS [Highest Salary]; i. GO Frank has various employees in different departments created in the following Departments and Employees tables: CREATE TABLE Departments ( Code nchar(4), Name nvarchar(40) ); GO CREATE TABLE Employees ( EmployeeNumber nchar(6) not null unique, [Full Name] nvarchar(50), HourlySalary money, Department nchar(4) ); GO INSERT Departments VALUES(N'HMNR', N'Human Resources'), (N'ACNT', N'Accounting'), (N'RNDV', N'Research & Development'); GO INSERT Employees VALUES(N'60-224', N'Frank Roberts', 20.15, N'RNDV'), (N'29-742', N'Marcial Engolo', 12.58, N'HMNR'), (N'82-073', N'John Duchant', 22.75, N'RNDV'),

(N'66-080', (N'82-503', (N'47-582', (N'82-263',

N'Mark Roberts', 10.12, N'HMNR'), N'Marthe Mengue', 15.86, N'ACNT'), N'Hervey Arndt', 12.24, N'HMNR'), N'Mark Edwards', 18.14, N'RNDV');

GO He wants to find the highest salary in the human resources department. What code can he use to get it? . SELECT MAX(HourlySalary) a. FROM Employees empl INNER JOIN Departments dept b. ON empl.Department = dept.Code c. WHERE dept.Code = N'RNDV'; d. GO e. SELECT MAX(HourlySalary) f. FROM Employees empl INNER JOIN Departments dept g. ON empl.Department = dept.Code h. WHERE dept.Code = N'HMNR'; i. GO j. SELECT MAX(HourlySalary) k. FROM Employees empl CROSS OUTER JOIN Departments dept l. ON empl.Department = dept.Code m. WHERE dept.Code = N'HMNR'; n. GO o. SELECT HIGH(HourlySalary) p. FROM Employees empl INNER JOIN Departments dept q. ON empl.Department = dept.Code r. WHERE NOT dept.Code = N'RNDV'; s. GO t. SELECT sp_high(HourlySalary) u. FROM Employees empl JOIN Departments dept v. ON empl.Department = dept.Code w. WHERE dept.Code = N'HMNR'; x. GO Lynda has the following table and its records: CREATE TABLE Employees ( EmployeeNumber nchar(6) not null unique, [Full Name] nvarchar(50), HourlySalary money, Manager nchar(6) ); GO INSERT Employees VALUES(N'60-224', N'Frank Roberts', 20.15, NULL), (N'29-742', N'Marcial Engolo', 12.58, NULL), (N'82-073', N'John Duchant', 22.74, N'29-742'), (N'82-503', N'Marthe Mengue', 15.86, N'60-224'), (N'44-440', N'Paul Motto', 16.22, N'29-742'), (N'47-582', N'Hervey Arndt', 12.24, N'60-224'), (N'82-263', N'Mark Edwards', 18.14, N'29-742'); GO She wants to get the list of employees with the last column showing each employee's manager name. What code would produce that list? . SELECT empl.EmployeeNumber AS [Empl #], a. empl.[Full Name], b. empl.HourlySalary AS Salary,

c. (SELECT mgr.[Full Name] d. FROM Employees mgr e. WHERE empl.Manager = mgr.EmployeeNumber) AS Manager f. FROM Employees empl; g. GO h. SELECT empl.EmployeeNumber AS [Empl #], i. empl.[Full Name], j. empl.HourlySalary AS Salary, k. (SELECT mgr.EmployeeNumber, mgr.[Full Name] l. FROM Employees mgr m. WHERE empl.Manager = mgr.EmployeeNumber) AS Manager n. FROM Employees empl; o. GO p. SELECT empl.EmployeeNumber AS [Empl #], q. empl.[Full Name], r. empl.HourlySalary AS Salary, s. (SELECT mgr.[Full Name] t. FROM Employees mgr u. WHERE empl.Manager = mgr.Manager) AS Manager v. FROM Employees empl; w. GO x. SELECT empl.EmployeeNumber AS [Empl #], y. empl.[Full Name], z. empl.HourlySalary AS Salary, aa. (SELECT mgr.EmployeeNumber bb. FROM Employees mgr cc. WHERE empl.Manager = mgr.EmployeeNumber) AS Manager dd. FROM Employees empl; ee. GO ff. SELECT empl.EmployeeNumber AS [Empl #], gg. empl.[Full Name], hh. empl.HourlySalary AS Salary, ii. (SELECT mgr.[Full Name] jj. FROM Employees mgr kk. WHERE empl.[Full Name] = mgr.[Full Name]) AS Manager ll. FROM Employees empl; mm. GO Janice has the following table and its records: CREATE TABLE Employees ( EmployeeNumber nchar(6) not null unique, [Full Name] nvarchar(50), HourlySalary money, Manager nchar(6) ); GO INSERT Employees VALUES(N'60-224', N'Frank Roberts', 20.15, NULL), (N'29-742', N'Marcial Engolo', 12.58, NULL), (N'82-073', N'John Duchant', 22.74, N'29-742'), (N'82-503', N'Marthe Mengue', 15.86, N'60-224'), (N'44-440', N'Paul Motto', 16.22, N'29-742'), (N'47-582', N'Hervey Arndt', 12.24, N'60-224'), (N'82-263', N'Mark Edwards', 18.14, N'29-742'); GO

She wants to get the list of employees with the last column showing each employee's manager name but the list must include only the employees who have a manager. What code would produce that list? . SELECT empl.EmployeeNumber AS [Empl #], a. empl.[Full Name], b. empl.HourlySalary AS Salary, c. (SELECT mgr.[Full Name] d. FROM Employees mgr e. WHERE empl.Manager = mgr.EmployeeNumber) AS Manager f. FROM Employees empl g. WHERE empl.Manager IS NOT NULL; h. GO i. SELECT empl.EmployeeNumber AS [Empl #], j. empl.[Full Name], k. empl.HourlySalary AS Salary, l. (SELECT mgr.[Full Name] m. FROM Employees mgr n. WHERE (empl.Manager = mgr.EmployeeNumber) o. AND empl.Manager IS NOT NULL) AS Manager p. FROM Employees empl; q. GO r. SELECT empl.EmployeeNumber AS [Empl #], s. empl.[Full Name], t. empl.HourlySalary AS Salary, u. (SELECT mgr.[Full Name] v. FROM Employees mgr w. WHERE empl.Manager = mgr.Manager) AS Manager IS NOT NULL x. FROM Employees empl; y. GO z. SELECT empl.EmployeeNumber AS [Empl #], aa. empl.[Full Name], bb. empl.HourlySalary AS Salary, cc. (SELECT mgr.EmployeeNumber dd. FROM Employees mgr ee. WHERE (empl.Manager = mgr.EmployeeNumber) ff. AND empl.Manager IS NOT NULL) AS Manager gg. FROM Employees empl; hh. GO ii. SELECT empl.EmployeeNumber AS [Empl #], jj. empl.[Full Name], kk. empl.HourlySalary AS Salary, ll. (SELECT mgr.[Full Name] NOT NULL mm. FROM Employees mgr nn. WHERE empl.[Full Name] = mgr.[Full Name]) AS Manager oo. FROM Employees empl; pp. GO Ann created the following table of employees and filled it up with the necessary records as follows: CREATE TABLE Employees ( EmployeeNumber nchar(6) not null unique, [Full Name] nvarchar(50), Manager nchar(6) ); GO

INSERT Employees VALUES(N'60-224', N'Frank Roberts', NULL), (N'29-742', N'Marcial Engolo', NULL), (N'82-073', N'John Duchant', N'29-742'), (N'82-503', N'Marthe Mengue', N'60-224'), (N'44-440', N'Paul Motto', N'29-742'), (N'47-582', N'Hervey Arndt', N'60-224'), (N'82-263', N'Mark Edwards', N'29-742'); GO To keep employee's personal information private, she created an additional table that contains employees salaries as follows: CREATE TABLE Salaries ( SalaryID int identity(1, 1) primary key, EmployeeNumber nchar(6) not null, HourlySalary money not null, ); GO INSERT Salaries(EmployeeNumber, HourlySalary) VALUES(N'60-224', 20.15), (N'29-742', 12.58), (N'82-073', 22.74), (N'82-503', 15.86), (N'44-440', 16.22), (N'47-582', 12.24), (N'82-263', 18.14); GO Now, Ann wants to see the list of employees so that each record shows an employee's salary and his or her manager name. What code would produce that result? . SELECT empl.EmployeeNumber AS [Empl #], a. empl.[Full Name], b. (SELECT sal.SalaryID, sal.HourlySalary c. FROM Salaries sal d. WHERE empl.EmployeeNumber = sal.EmployeeNumber) AS Salary, e. (SELECT mgr.EmployeeNumber, mgr.[Full Name] f. FROM Employees mgr g. WHERE empl.Manager = mgr.EmployeeNumber) AS Manager h. FROM Employees empl; i. GO j. SELECT empl.EmployeeNumber AS [Empl #], k. empl.[Full Name], l. (SELECT sal.HourlySalary m. FROM Salaries sal n. WHERE empl.EmployeeNumber = sal.EmployeeNumber) AS Salary, o. (SELECT mgr.[Full Name] p. FROM Employees mgr q. WHERE empl.Manager = mgr.EmployeeNumber) AS Manager r. FROM Employees empl; s. GO t. SELECT empl.EmployeeNumber AS [Empl #], u. empl.[Full Name],

v. (SELECT sal.HourlySalary w. FROM Salaries sal x. WHERE empl.EmployeeNumber = sal.SalaryID) AS Salary, y. (SELECT mgr.[Full Name] z. FROM Employees mgr aa. WHERE empl.Manager = mgr.EmployeeNumber) AS Manager bb. FROM Employees empl; cc. GO dd. SELECT empl.EmployeeNumber AS [Empl #], ee. empl.[Full Name], ff. (SELECT sal.EmployeeNumber gg. FROM Salaries sal hh. WHERE empl.EmployeeNumber = sal.EmployeeNumber) AS Salary, ii. (SELECT mgr.EmployeeNumber jj. FROM Employees mgr kk. WHERE empl.SalaryID = mgr.SalaryID) AS Manager ll. FROM Employees empl; mm. GO nn. SELECT empl.EmployeeNumber AS [Empl #], oo. empl.[Full Name], pp. (SELECT sal.EmployeeNumber qq. FROM Salaries sal rr. WHERE empl.EmployeeNumber = sal.EmployeeNumber) AS Salary, ss. (SELECT mgr.EmployeeNumber tt. FROM Employees mgr uu. WHERE empl.Manager = mgr.EmployeeNumber) AS Manager vv. FROM Employees empl; ww. GO To monitor the base salaries of employees in his company, John's has a table named StartingSalaries as follows: CREATE SCHEMA Personnel; GO CREATE TABLE Personnel.StartingSalaries ( Category nvarchar(30) not null, StartingSalary money null ); INSERT INTO Personnel.StartingSalaries VALUES(N'Base', 10.00), (N'Intern', 12.35), (N'Regular', 14.50), (N'Manager', 20.00); GO John also has a table of employees as follows: CREATE TABLE Personnel.Employees ( EmployeeID int identity(1,1) NOT NULL, EmployeeNumber nchar(10), FirstName nvarchar(32), LastName nvarchar(32) NOT NULL, Title nvarchar(50), HourlySalary money, CONSTRAINT PK_Employees PRIMARY KEY (EmployeeID)

); GO INSERT INTO Personnel.Employees(EmployeeNumber, FirstName, LastName, Title, HourlySalary) VALUES(N'662-286', N'Lienev', N'Zbrnitz', N'Cashier', 15.75), (N'487-525', N'Paulin', N'Guerrero', N'Intern', 10.85), (N'395-138', N'Plant', N'Waste', N'Head Teller', 16.75), (N'822-730', N'Steven', N'Chang', N'Intern', 14.15), (N'930-717', N'Abedi', N'Kombo', N'Shift Leader', 10.02), (N'573-048', N'Paul', N'Landsford', N'Cashier', 12.25); GO Now, John wants to get a list of employees whose salary is lower than the intern's salary of the StartingSalaries table. What code can John use: . SELECT empl.* a. FROM Personnel.Employees empl b. WHERE empl.Title <= (SELECT Category c. FROM Personnel.StartingSalaries sal); d. GO e. SELECT empl.* f. FROM Personnel.Employees empl g. WHERE empl.HourlySalary <= (SELECT sal.Category h. FROM Personnel.StartingSalaries sal i. WHERE sal.StartingSalary = 12.35); j. GO k. SELECT empl.* l. FROM Personnel.Employees empl m. WHERE empl.HourlySalary <= (SELECT sal.StartingSalary n. FROM Personnel.StartingSalaries sal o. WHERE sal.Category = N'Intern'); p. GO q. SELECT empl.EmployeeNumber, r. empl.FirstName, s. empl.LastName, t. empl.Title, u. (SELECT sal.StartingSalary v. FROM Personnel.StartingSalaries sal w. WHERE sal.Category = N'Intern') x. FROM Personnel.Employees empl; y. GO z. SELECT empl.EmployeeNumber, aa. empl.FirstName, bb. empl.LastName, cc. empl.Title, dd. (SELECT sal.Category ee. FROM Personnel.StartingSalaries sal ff. WHERE sal.StartingSalary = 12.3500) gg. FROM Personnel.Employees empl; hh. GO Eric has the following tables and their records: CREATE TABLE Departments ( DepartmentCode nchar(6) not null primary key, DepartmentName nvarchar(50) not null ); GO

INSERT INTO Departments VALUES(N'HMRS', N'Human Resources'), (N'ACNT', N'Accounting'), (N'PSNL', N'Personnel'), (N'RSDV', N'Research & Development'); GO CREATE TABLE Employees ( EmployeeNumber nchar(10) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), DepartmentCode nchar(6) ); GO INSERT INTO Employees VALUES(N'283-947', N'Timothy', N'White', N'RSDV'), (N'572-384', N'Jeannette', N'Welch', N'PSNL'), (N'279-242', N'Ann', N'Welch', N'HMRS'), (N'495-728', N'Robert', N'Simms', N'RSDV'), (N'382-505', N'Paula', N'Waters', N'PSNL'), (N'268-046', N'Martine', N'Nyamoto', N'ACNT'), (N'773-148', N'James', N'Larsen', N'RSDV'), (N'958-057', N'Peter', N'Aut', N'HMRS'); GO He wants to move all employees from the personnel department to the human resources department. Which of the following codes would produce the right result? . UPDATE Employees a. SET DepartmentCode = N'PSNL' b. WHERE DepartmentCode = N'HMRS'; c. GO d. UPDATE Employees e. SET DepartmentCode = N'HMRS' f. WHERE DepartmentCode = N'PSNL'; g. GO h. UPDATE FROM Employees i. SET DepartmentCode = N'PSNL' j. WHERE DepartmentCode = N'HMRS'; k. GO l. SET Employees m. UPDATE DepartmentCode = N'HMRS' n. WHERE DepartmentCode = N'PSNL'; o. GO p. SET Employees q. UPDATE DepartmentCode = N'PSNL' r. WHERE DepartmentCode = N'HMRS'; s. GO You have a table named ObsoleteProducts and you are asked to remove all of its records. What code would you use to do it? . a. b. c. d. DROP ObsoleteProducts; REMOVE ALL * FROM ObsoleteProducts; DELETE * FROM ObsoleteProducts; DELETE ObsoleteProducts; EXECUTE sp_removerecords FROM ObsoleteProducts;

Consider the following table of employees:

CREATE TABLE Employees ( EmployeeNumber nchar(10) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), DepartmentCode nchar(6) ); Imagine you want to provide your users with a view that shows the employees numbers and their name. What code can you use to create such a view? . CREATE VIEW EmployeesRecords a. BEGIN b. SELECT empl.EmployeeNumber, empl.FirstName, empl.LastName c. FROM Employees empl; d. END e. CREATE VIEW EmployeesRecords f. AS g. SELECT empl.EmployeeNumber, empl.FirstName, empl.LastName h. FROM Employees empl; i. CREATE VIEW EmployeesRecords j. RETURN TABLE k. AS l. SELECT empl.EmployeeNumber, empl.FirstName, empl.LastName m. FROM Employees empl; n. CREATE VIEW EmployeesRecords1 o. WITH SELECT empl.EmployeeNumber, empl.FirstName, empl.LastName p. FROM Employees empl; q. END r. EXECUTE CREATE EmployeesRecords1 AS VIEW s. SELECT empl.EmployeeNumber, empl.FirstName, empl.LastName t. FROM Employees empl; Imagine you have the following table: CREATE TABLE Employees ( EmployeeNumber nchar(10) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), DepartmentCode nchar(6) ); GO Now you want to change the table to add a column named HourlySalary of type money. What code would you use to do that? . UPDATE TABLE Employees a. BEGIN b. ADD HourlySalary money; c. END d. ALTER TABLE Employees ADD HourlySalary money; e. EXECUTE MODIFY TABLE Employees f. AS g. ADD HourlySalary money; h. END i. EXECUTE sp_change TABLE Employees j. AS k. BEGIN l. ADD HourlySalary money; m. END

n. o. p. q. r.

ALTER TABLE Employees AS BEGIN ADD COLUMN HourlySalary money; END

You inherited a table that was created as follows: CREATE TABLE Employees ( FirstName nvarchar(20), LastName nvarchar(20), DepartmentCode nchar(6) ); GO Now you want to add a primary key column named EmployeeNumber of type int. What two codes can you use to perform that operation? . WITH Employees a. SET EmployeeNumber int not null PRIMARY KEY(EmployeeNumber); b. GO c. ALTER TABLE Employees d. ADD EmployeeNumber int not null PRIMARY KEY; e. GO f. ALTER TABLE Employees g. ADD EmployeeNumber int not null h. CONSTRAINT PK_Employees PRIMARY KEY(EmployeeNumber); i. GO j. UPDATE TABLE Employees k. ADD COLUMN EmployeeNumber int not null PRIMARY KEY(EmployeeNumber); l. GO m. ALTER TABLE Employees n. ADD EmployeeNumber int not null o. ALTER EmployeeNumber AS PRIMARY KEY(EmployeeNumber); p. GO Mark has a table of employees and it contains a column named LastName. Mark wants to get a list of employees whose last name ends with the letter a. What code can he use? . a. b. c. d. e. f. g. h. i. j. k. l. m. n. SELECT ALL * FROM Employees WHERE LastName LIKE N'%a'; GO SELECT ALL * FROM Employees WHERE LastName LIKE N'_a'; GO SELECT ALL * FROM Employees WHERE LastName LIKE N'[a]'; GO SELECT * FROM Employees WHERE LastName LIKE N'[^a]'; GO SELECT ALL * FROM Employees WHERE LastName LIKE N'!a'; GO

Alex has the following table named Products: CREATE TABLE Products

( ItemNumber int primary key, Name nvarchar(50), UnitPrice money, Discount decimal(4, 2) ); Many records have been added to the table. Some records have a value for the discount and some do not. To get a list of products that do not have a discount, what code can Alex use? . SELECT ItemNumber, Name, UnitPrice, Discount a. FROM Products b. WHERE Discount = 0; c. GO d. SELECT ItemNumber, Name, UnitPrice, Discount e. FROM Products f. WHERE Discount = NULL; g. GO h. SELECT * i. FROM Products j. WHERE Discount <> 0; k. SELECT * l. FROM Products m. WHERE Discount NULL; n. SELECT ItemNumber, Name, UnitPrice, Discount o. FROM Products p. WHERE Discount IS NULL; Mark is creating a view based on an Employees table. He wants the statement that creates the view to be scrambled when added to the database. What code can mark use to do this? . a. b. c. d. e. f. g. h. i. j. k. l. m. n. o. p. q. r. s. t. u. v. w. x. y. CREATE VIEW Payroll SET ENCRYPTION ON AS SELECT EmployeeNumber, FROM Employees GO CREATE VIEW Payroll AS SELECT EmployeeNumber, FROM Employees; ENCRYPT WHEN DONE GO CREATE VIEW Payroll WITH ENCRYPTION AS SELECT EmployeeNumber, FROM Employees GO CREATE VIEW Payroll AS SELECT EmployeeNumber, FROM Employees; WITH ENCRYPTION GO CREATE VIEW Payroll AS

FirstName, LastName, HourlySalary

FirstName, LastName, HourlySalary

FirstName, LastName, HourlySalary

FirstName, LastName, HourlySalary

z. aa. bb. cc.

SELECT EmployeeNumber, FirstName, LastName, HourlySalary FROM Employees SET ENCRYPTION ON GO

You want to allow an employee whose login name is Peter to be able to change the design or code of a table named Employees of the Personnel schema. What code would allow you to do that? . a. b. c. d. e. f. g. h. i. j. k. l. m. SELECT ALL USERS FROM Personnel.Employees GRANT ALTER TO Peter; GRANT ALTER ON OBJECT::Personnel.Employees TO Peter; EXECUTE sp_grant(ALTER) TO Peter ON OBJECT::Personnel.Employees; GRANT PERMISSION ALTER TO Peter ON OBJECT::Personnel.Employees; SET PERMISSION ALTER ON OBJECT::Personnel.Employees TO Peter;

Jimmy has a table named Employees created in a schema named Personnel. He wants to create a view named Payroll in the same schema but he wants to make sure that no change in the Employees table is allowed if that change would affect the Payroll view. What code can he use to accomplish that? . CREATE VIEW Personnel.Payroll a. DO SCHEMA BINDING b. AS c. SELECT EmployeeNumber, FirstName, LastName, HourlySalary d. FROM Personnel.Employees e. GO f. CREATE VIEW Personnel.Payroll g. AS h. WITH SCHEMA BINDING i. SELECT EmployeeNumber, FirstName, LastName, HourlySalary j. FROM Personnel.Employees k. GO l. CREATE VIEW Personnel.Payroll m. FOR SCHEMABINDING n. AS o. SELECT EmployeeNumber, FirstName, LastName, HourlySalary p. FROM Personnel.Employees q. GO r. CREATE VIEW Personnel.Payroll s. WITH SCHEMABINDING t. AS u. SELECT EmployeeNumber, FirstName, LastName, HourlySalary v. FROM Personnel.Employees w. GO x. CREATE VIEW Personnel.Payroll y. AS z. SELECT EmployeeNumber, FirstName, LastName, HourlySalary aa. FROM Personnel.Employees bb. SET SCHEMA BINDING ON

cc.

GO

Harriett has the following table of employees: CREATE TABLE Personnel.Employees ( EmployeeNumber nchar(7) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), EmploymentStatus smallint, HourlySalary money ); GO INSERT Personnel.Employees VALUES(N'284-680', N'Anselme', N'Bongos', 2, 18.62), (N'730-704', N'June', N'Malea', 1, 9.95); (N'735-407', N'Frank', N'Monson', 3, 14.58), (N'281-730', N'Jerry', N'Beaulieu', 1, 16.65); GO Harriett also has the following table of sales made by employees during a certain period: CREATE TABLE Commercial.Sales ( SaleID int identity(1, 1), EmployeeNumber nchar(7) not null, SaleDate date, Amount money ); GO INSERT INTO Commercial.Sales(EmployeeNumber, SaleDate, Amount) VALUES(N'284-680', N'2011-02-14', 4250), (N'735-407', N'2011-02-14', 5300), (N'730-704', N'2011-02-14', 2880), (N'281-730', N'2011-02-14', 4640), (N'284-680', N'2011-02-15', 4250), (N'281-730', N'2011-02-15', 3675), (N'735-407', N'2011-02-15', 3420), (N'730-704', N'2011-02-15', 3675), (N'284-680', N'2011-02-16', 5500), (N'281-730', N'2011-02-16', 2675), (N'735-407', N'2011-02-16', 4400), (N'730-704', N'2011-02-16', 2605); GO Now, Harriett wants to see the highest sales made by employees but the list must include only employees who sold over 4750. What code can she use? . SELECT LastName + N', ' + FirstName, MAX(Amount) a. FROM Commercial.Sales cs JOIN b. Personnel.Employees pe ON c. cs.EmployeeNumber = pe.EmployeeNumber d. HAVING MAX(Amount) > 4750.00; e. GROUP BY LastName + N', ' + FirstName f. GO g. SELECT LastName + N', ' + FirstName, MAX(Amount) h. FROM Commercial.Sales cs JOIN i. Personnel.Employees pe ON j. cs.EmployeeNumber = pe.EmployeeNumber k. GROUP BY LastName + N', ' + FirstName

l. HAVING SUM(Amount) > 4750.00; m. GO n. SELECT LastName + N', ' + FirstName, MAX(Amount) o. FROM Commercial.Sales cs JOIN p. Personnel.Employees pe ON q. cs.EmployeeNumber = pe.EmployeeNumber r. GROUP BY LastName + N', ' + FirstName s. HAVING MAX(Amount) > 4750.00; t. GO u. SELECT LastName + N', ' + FirstName, MAX(Amount) v. FROM Commercial.Sales cs JOIN w. Personnel.Employees pe ON x. cs.EmployeeNumber = pe.EmployeeNumber y. GROUP BY LastName + N', ' + FirstName z. WHERE Amount > 4750.00; aa. GO bb. SELECT LastName + N', ' + FirstName, MAX(Amount) cc. FROM Commercial.Sales cs JOIN dd. Personnel.Employees pe ON ee. cs.EmployeeNumber = pe.EmployeeNumber ff. GROUP BY LastName + N', ' + FirstName gg. HAVING MAX(Amount) > 4750.00 hh. WHERE Amount IS NOT NULL; ii. GO Charles has the following table of employees: CREATE TABLE Personnel.Employees ( EmployeeNumber nchar(7) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), EmploymentStatus smallint, HourlySalary money ); GO INSERT Personnel.Employees VALUES(N'284-680', N'Anselme', N'Bongos', 2, 18.62), (N'730-704', N'June', N'Malea', 1, 9.95); (N'735-407', N'Frank', N'Monson', 3, 14.58), (N'281-730', N'Jerry', N'Beaulieu', 1, 16.65); GO He also has the following table of sales made by employees during a certain period: CREATE TABLE Commercial.Sales ( SaleID int identity(1, 1), EmployeeNumber nchar(7) not null, SaleDate date, Amount money ); GO INSERT INTO Commercial.Sales(EmployeeNumber, SaleDate, Amount) VALUES(N'284-680', N'2011-02-14', 4250), (N'735-407', N'2011-02-14', 5300), (N'730-704', N'2011-02-14', 2880), (N'281-730', N'2011-02-14', 4640), (N'284-680', N'2011-02-15', 4250),

(N'281-730', N'2011-02-15', 3675); GO Charles wants to get the list employees so that each record shows the first name, the last name and the numer of sales the employee made. The list must show the number of sales in incremental order. What code can he use? . SELECT pe.LastName [First Name], pe.FirstName [Last Name], a. COUNT(cs.Amount) AS [Number of Sales] b. FROM Commercial.Sales cs JOIN c. Personnel.Employees pe ON d. cs.EmployeeNumber = pe.EmployeeNumber e. GROUP BY pe.LastName, pe.FirstName f. ORDER BY [Number of Sales]; g. SELECT pe.LastName [First Name], pe.FirstName [Last Name], h. COUNT(*) AS [Number of Sales] i. FROM Commercial.Sales cs JOIN j. Personnel.Employees pe ON k. cs.EmployeeNumber = pe.EmployeeNumber l. GROUP BY Amount m. ORDER BY Amount; n. SELECT pe.LastName AS [First Name], pe.FirstName AS [Last Name], o. COUNT(cs.Amount) AS [Number of Sales] p. FROM Commercial.Sales cs JOIN q. Personnel.Employees pe ON r. cs.EmployeeNumber = pe.EmployeeNumber s. GROUP BY cs.Amount t. HAVING cs..Amount u. ORDER BY cs.Amount; v. SELECT pe.LastName AS [First Name], pe.FirstName AS [Last Name], w. COUNT(*) AS [Number of Sales] x. GROUP BY cs.Amount y. FROM Commercial.Sales cs JOIN z. Personnel.Employees pe ON aa. cs.EmployeeNumber = pe.EmployeeNumber bb. ORDER BY cs.Amount; cc. SELECT pe.LastName AS [First Name], pe.FirstName AS [Last Name], dd. COUNT(cs.Amount) AS [Number of Sales] ee. ORDER BY cs.Amount ff. GROUP BY cs.Amount gg. FROM Commercial.Sales cs JOIN hh. Personnel.Employees pe ON ii. cs.EmployeeNumber = pe.EmployeeNumber; Imagine you have the following table: CREATE TABLE Contractors ( EmployeeID int identity(1, 1), FullName nvarchar(50), Wage money ); Imagine you want to rename the last column from Wage to HourlySalary. What code would let you do that? . RENAME COLUMN N'Contractors.Wage' AS N'Contractors.HourlySalary';

a. RENAME SET N'Contractors.Wage' AS N'Contractors.HourlySalary';

b. sp_rename N'Contractors.Wage', N'HourlySalary', N'COLUMN'; c. EXECUTE sp_changename COLUMN N'Contractors.Wage' TO N'HourlySalary' d. RENAME N'Wage' TO N'HourlySalary' FROM Contractors; Imagine you have a table named Employees that includes a column named EmploymentStatus but that column has become useless. What code can you use to delete that column? . a. b. c. d. e. f. g. h. i. j. k. l. m. n. ALTER TABLE Contractors DELETE COLUMN EmploymentStatus; GO ALTER TABLE Contractors SET EmploymentStatus = NULL; GO UPDATE TABLE Contractors DELETE EmploymentStatus; GO ALTER TABLE Contractors DROP COLUMN EmploymentStatus; GO UPDATE TABLE Contractors SET EmploymentStatus = NULL; GO

John has a table named Employees and another table named Products. The tables were created using the following code: CREATE TABLE Employees ( [Empl #] nchar(7), [First Name] nvarchar(20), [Last Name] nvarchar(20), [Hourly Salary] money ); GO CREATE TABLE Products ( Number int, Name nvarchar(50), UnitPrice money, ); GO INSERT INTO Employees VALUES(N'207-025', N'Julie', N'Flanell', 36.55), (N'926-705', N'Paulette', N'Simms', 26.65), (N'240-002', N'Alexandra', N'Ulm', 12.85), (N'847-295', N'Ellie', N'Tchenko', 11.95); GO INSERT INTO Products VALUES(217409, N'Short Black Skirt', 55.85), (790279, N'Classic Fit Pinpoint Shirt', 82.00), (284001, N'Pencil Skirt', 49.00); GO John wants to see a list of employees mixed with products. The list should include only products that cost more than 50.00. What code can he use? . SELECT [Empl #], [First Name], [Last Name], Name, UnitPrice

a. b. c. d. e. f. g. h. i. j. k. l. m. n. o. p. q. r. s. t. u. v. w. x. y. z.

FROM Employees, Products WHERE UnitPrice > 50; GO SELECT empl.[Empl #], empl.[First Name], empl.[Last empl.Name, DISTINCT(empl.UnitPrice) FROM Employees empl, Products prod WHERE empl.UnitPrice > 50; GO SELECT empl.[Empl #], empl.[First Name], empl.[Last prod.Name, prod.UnitPrice FROM Employees empl INNER JOIN Products prod ON empl.[Empl #] = prod.Number HAVING prod.UnitPrice > 50; GO SELECT empl.[Empl #], empl.[First Name], empl.[Last prod.Name, prod.UnitPrice FROM Employees empl JOIN Products prod ON empl.[Empl #] = prod.Number GROUP BY prod.UnitPrice HAVING prod.UnitPrice > 50; GO SELECT empl.[Empl #], empl.[First Name], empl.[Last prod.Name, prod.UnitPrice FROM Employees empl, Products prod HAVING prod.UnitPrice > 50; GO

Name],

Name],

Name],

Name],

Ashley has a table of employees created as follows: CREATE TABLE Employees ( EmployeeNumber nchar(7), [First Name] nvarchar(20), [Last Name] nvarchar(20), [Hourly Salary] money ); GO She wants to create a table named Sales so that each record in the Sales table indicates the employee who made the sale. What two codes can she use to create the new table? . CREATE TABLE Sales a. ( b. SaleID int IDENTITY(1, 1) PRIMARY KEY, c. SaleDate date, d. EmployeeNumber nchar(7), e. ProductName nvarchar(60), f. UnitPrice money, g. CONSTRAINT FK_Employees FOREIGN KEY REFERENCES Employees(EmployeeNumber) h. ); i. CREATE TABLE Sales j. ( k. SaleID int IDENTITY(1, 1) PRIMARY KEY, l. SaleDate date, m. EmployeeNumber nchar(7) FOREIGN KEY REFERENCES Employees(EmployeeNumber), n. ProductName nvarchar(60),

o. UnitPrice money, p. ); q. CREATE TABLE Sales r. ( s. SaleID int IDENTITY(1, 1) PRIMARY KEY, t. SaleDate date, u. EmployeeNumber nchar(7) v. CONSTRAINT FK_Employees FOREIGN KEY REFERENCES Employees(EmployeeNumber), w. ProductName nvarchar(60), x. UnitPrice money, y. z. ); aa. CREATE TABLE Sales bb. ( cc. SaleID int IDENTITY(1, 1) PRIMARY KEY, dd. SaleDate date, ee. EmployeeNumber nchar(7) ff. CONSTRAINT FOREIGN KEY REFERENCES Employees(EmployeeNumber), gg. ProductName nvarchar(60), hh. UnitPrice money, ii. jj. ); kk. CREATE TABLE Sales ll. ( mm. SaleID int IDENTITY(1, 1) PRIMARY KEY, nn. SaleDate date, oo. EmployeeNumber nchar(7), pp. ProductName nvarchar(60), qq. UnitPrice money, rr. CREATE FOREIGN KEY WITH EmployeeNumber FROM Employees ss. tt. ); Imagine you have an index named IDX_Customers on a table named Customers but you don't need that index anymore. What code can you use to delete that index? . a. b. c. d. DROP INDEX IDX_Customers ON Customers(AccountNumber); DELETE INDEX IDX_Customers ON Customers; DROP INDEX IDX_Customers FROM Customers; DROP INDEX IDX_Customers ON Customers; DELETE INDEX IDX_Customers AccountNumber FROM Customers;

Jason had created two tables as follows: CREATE TABLE Employees ( EmployeeNumber nchar(7) PRIMARY KEY, FirstName nvarchar(20), LastName nvarchar(20), HourlySalary money ); GO CREATE TABLE Sales ( SaleID int IDENTITY(1, 1) PRIMARY KEY, SaleDate date,

ProductName nvarchar(60), UnitPrice money ); GO Now he wants to add a column to the Sales table so that the new field gets its values from the Employees table. How can he write code to do that? . ALTER TABLE Sales a. ADD FOREIGN KEY EmployeeNumber nchar(7) FOR Employees(EmployeeNumber); b. UPDATE TABLE Sales c. ADD COLUMN EmployeeNumber nchar(7) FOREIGN KEY Employees(EmployeeNumber); d. GO e. CHANGE TABLE Sales f. ADD EmployeeNumber nchar(7) FOREIGN KEY Employees(EmployeeNumber); g. GO h. UPDATE TABLE Sales i. ADD FOREIGN KEY AS EmployeeNumber nchar(7) j. REFERENCES EmployeeNumber FROM Employees; k. ALTER TABLE Sales l. ADD EmployeeNumber nchar(7) FOREIGN KEY REFERENCES Employees(EmployeeNumber); Jimmy wants to create a custom data type named Integer and based on the int data type. How can he write to accomplish that? . a. b. c. d. CREATE DATATYPE Integer FROM int; EXECUTE sp_createtype Integer AS Natural; CREATE TYPE SET Integer = int; CREATE OBJECT:TYPE Integer FROM int; CREATE TYPE Integer FROM int;

In order to rightly perform data analysis on a database with international names, Jimmy wants to add a flag on a string-based column. What code can he use to take or latinbased characters? . a. b. c. d. e. f. g. h. i. j. k. l. m. n. o. p. q. r. s. t. CREATE TABLE Customers ( CustomerID int identity(1, 1), FullName nvarchar(50), PhoneNumber nvarchar(20) ) WITH COLLATE SQL_Latin1_General_CP1_CI_AS; WITH COLLATE SQL_Latin1_General_CP1_CI_AS BEGIN CREATE TABLE Customers ( CustomerID int identity(1, 1), FullName nvarchar(50), PhoneNumber nvarchar(20) ) END; CREATE TABLE Customers ( CustomerID int identity(1, 1), FullName nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS, PhoneNumber nvarchar(20)

u. ); v. CREATE TABLE Customers w. ( x. CustomerID int identity(1, 1), y. FullName nvarchar(50) WITH COLLATE SQL_Latin1_General_CP1_CI_AS, z. PhoneNumber nvarchar(20) aa. ); bb. CREATE TABLE Customers cc. ( dd. CustomerID int identity(1, 1), ee. FullName nvarchar(50), ff. PhoneNumber nvarchar(20), gg. CONSTRAINT CT_Customers COLLATE SQL_Latin1_General_CP1_CI_AS hh. ); Michael has a database with a table named Customers. He created a user named James Galvin and he wants to give him the ability to create new records or update existing records on that table. What code can he use? . a. b. c. d. e. f. g. h. i. j. k. l. m. n. o. p. q. r. s. GRANT INSERT, UPDATE ON OBJECT::Sales.Customers TO [James Galvin]; GO GRANT INSERT, UPDATE TO [James Galvin]; ON OBJECT::Sales.Customers GO SET GRANT INSERT, UPDATE ON OBJECT::Sales.Customers TO N'James Galvin'; GO GRANT INSERT AND UPDATE FOR OBJECT::Sales.Customers TO [James Galvin]; GO WITH GRANT INSERT, UPDATE SET OBJECT::Sales.Customers TO [James Galvin]; GO

Imagine you have already created a login name for an employee as jpalau. Now you that employee to be able to create databases on the server. What code would you use to give that right? . a. b. c. d. e. f. g. h. i. GRANT CREATE DATABASES TO jpalau; FOR ANY DATABASE GRANT CREATE TO jpalau; WITH OBJECT::jpalau GRANT CREATE ANY DATABASE; GRANT CREATE ANY DATABASE TO jpalau; EXECUTE CREATE ANY DATABASE FOR USER::jpalau;

Mike has already created two login names as gsanders and hnorm for two employees. He wants to give each the ability to create databases on the server and be able to change the login account of other employees. What code can he use to take care of that? . a. b. c. d. e. f. g. h. i. j. k. l. m. n. o. p. q. r. s. t. u. v. w. x. y. z. WITH gsanders, hnorm GRANT CREATE ANY DATABASE, ALTER ANY LOGIN; GO GRANT CREATE ANY DATABASE, ALTER ANY LOGIN TO gsanders, hnorm; GO GRANT PERMISSION::CREATE ANY DATABASE, PERMISSION::ALTER ANY LOGIN TO gsanders, hnorm; GO GRANT PERMISSION(CREATE ANY DATABASE, ALTER ANY LOGIN) TO OBJECT::gsanders; GO GRANT PERMISSION(CREATE ANY DATABASE, ALTER ANY LOGIN) TO OBJECT::hnorm; GO EXECUTE GRANT PERMISSION SET CREATE ANY DATABASE = TRUE SET ALTER ANY LOGIN = TRUE TO OBJECT::gsanders; GO EXECUTE GRANT PERMISSION SET CREATE ANY DATABASE = TRUE SET ALTER ANY LOGIN = TRUE TO OBJECT::hnorm; GO

You have a table of products that was created as follows: CREATE TABLE Products ( ProductCode nchar(6) not null, Name nvarchar(50) not null, UnitPrice money not null, CONSTRAINT PK_Products PRIMARY KEY(ProductCode) ); When you add a few records, you want to immediately see the list of records that were added. What example of code would do that? . INSERT Products a. VALUES(N'293804', N'Mid Lady Bag - Lizard', 228), b. (N'400571', N'Holly Gladiator Heel Shoes', 198) c. OUTPUT inserted.*; d. INSERT Products e. VALUES(N'293804', N'Mid Lady Bag - Lizard', 228), f. (N'400571', N'Holly Gladiator Heel Shoes', 198) g. SHOW OUTPUT; h. INSERT Products i. OUTPUT inserted.* j. VALUES(N'293804', N'Mid Lady Bag - Lizard', 228), k. (N'400571', N'Holly Gladiator Heel Shoes', 198); l. INSERT Products m. SELECT VALUES(N'293804', N'Mid Lady Bag - Lizard', 228),

n. (N'400571', N'Holly Gladiator Heel Shoes', 198); o. WHEN INSERT Products p. VALUES(N'293804', N'Mid Lady Bag - Lizard', 228), q. (N'400571', N'Holly Gladiator Heel Shoes', 198) r. GO TO OUTPUT INSERT; Barbara is creating a table of products that will contain columns named ProductID, Name, and UnitPrice. The value for the product number must be an integer automatically generated by the database engine, the name will be a string with a maximum of 50 characters, and the unit price will be set to the local currency. What code can she use to create the table? . CREATE TABLE Products a. ( b. ProductID int AUTONUMBER, c. Name nvarchar(50), d. UnitPrice money e. ); f. GO g. CREATE TABLE Products h. ( i. ProductID int COUNTER, j. Name nvarchar(50), k. UnitPrice money l. ); m. GO n. CREATE TABLE Products o. ( p. ProductID int AUTOINCREMENT, q. Name nvarchar(50), r. UnitPrice money s. ); t. GO u. CREATE TABLE Products v. ( w. ProductID int IDENTITY(1, 1), x. Name nvarchar(50), y. UnitPrice money z. ); aa. GO bb. CREATE TABLE Products cc. ( dd. ProductID int, ee. Name nvarchar(50), ff. UnitPrice money, gg. CONSTRAINT AI_Products IDENTITY(ProductID) hh. ); ii. GO Diane created a table of products that includes a column named ProductID that automatically gets its values from the database engine. The table was created as follows: CREATE TABLE Products ( ProductID int identity(1, 1), Name nvarchar(50), UnitPrice money );

GO Diane wants to add a new record but she wants to specify the product number. What code can she use to create the table? . SET IDENTITY_INSERT Products ON; a. GO b. INSERT Products(ProductID, Name, UnitPrice) c. VALUES(1002, N'Mid Lady Bag - Lizard', 228), d. (84, N'Holly Gladiator Heel Shoes', 198), e. (519, N'Short Black Skirt', 55.85); f. GO g. WITH IDENTITY_INSERT ON Products; h. GO i. INSERT Products(ProductID, Name, UnitPrice) j. VALUES(1002, N'Mid Lady Bag - Lizard', 228), k. (84, N'Holly Gladiator Heel Shoes', 198), l. (519, N'Short Black Skirt', 55.85); m. GO n. WITH AUTOINCREMENT = FALSE; o. GO p. INSERT Products(ProductID, Name, UnitPrice) q. VALUES(1002, N'Mid Lady Bag - Lizard', 228), r. (84, N'Holly Gladiator Heel Shoes', 198), s. (519, N'Short Black Skirt', 55.85); t. GO u. SET IDENTITY ON Products = NULL; v. GO w. INSERT Products(ProductID, Name, UnitPrice) x. VALUES(1002, N'Mid Lady Bag - Lizard', 228), y. (84, N'Holly Gladiator Heel Shoes', 198), z. (519, N'Short Black Skirt', 55.85); aa. INSERT Products(ProductID, Name, UnitPrice) bb. WITH IDENTITY_INSERT = TRUE cc. VALUES(1002, N'Mid Lady Bag - Lizard', 228), dd. (84, N'Holly Gladiator Heel Shoes', 198), ee. (519, N'Short Black Skirt', 55.85); Justin has a table named Products and that has a few records. The table was created as follows: CREATE TABLE Products ( ProductID int identity(1, 1) not null, Name nvarchar(50), Size nvarchar(32), UnitPrice money, DiscountRate decimal(4, 2), CONSTRAINT PK_Products PRIMARY KEY(ProductID) ); Justin wants to get a list of product names, their sizes and prices. He also wants the list to be sorted alphabetically according to the names. What code can he use to do that? . SELECT Name, Size, UnitPrice a. FROM Products b. SORT(Name); c. GO d. SELECT SORT(Name), Size, UnitPrice e. FROM Products;

f. g. h. i. j. k. l. m. n. o. p. q. r.

GO SELECT Name, Size, UnitPrice ORDER BY Name FROM Products; GO SELECT Name, Size, UnitPrice FROM Products ORDER BY Name; GO SELECT Name, Size, UnitPrice SET SORT FOR Name FROM Products; GO

Linette has a table named Products and that has a few records. The table was created as follows: CREATE TABLE Products ( ProductID int identity(1, 1) not null, DateAcquired date, Name nvarchar(50), Size nvarchar(32), UnitPrice money, DiscountRate decimal(4, 2), CONSTRAINT PK_Products PRIMARY KEY(ProductID) ); GO INSERT Products(DateAcquired, Name, UnitPrice) VALUES(N'2011-12-06', N'Mid Lady Bag - Lizard', 228), (N'2010-08-09', N'Midnight Floral Cardigan', 78), (N'2011-10-12', N'Zip Front Sheath Dress', 138), (N'2010-05-24', N'Holly Gladiator Heel Shoes', 198), (N'2011-02-16', N'Short Black Skirt', 55.85); GO Linette wants to get a list of products using with the date they were acquired, their names, their sizes and prices. He also wants the list to be sorted by the acquired dates from the most recent to the oldest item. What code can he use to do that? . SELECT DateAcquired, Name, Size, UnitPrice a. FROM Products b. ORDER BY DateAcquired ASC; c. GO d. SELECT DateAcquired, Name, Size, UnitPrice e. FROM Products f. ORDER BY DateAcquired DESC; g. GO h. SELECT DateAcquired, Name, Size, UnitPrice i. SORT(DateAcquired) ASCENDING j. FROM Products; k. GO l. SELECT DateAcquired, Name, Size, UnitPrice m. FROM Products n. ORDER BY DateAcquired DESCENDING; o. GO p. SELECT DateAcquired, Name, Size, UnitPrice q. SET SORT FOR DateAcquired ASC r. FROM Products;

s. GO Stan created a table named Products and filled it with records as follows: CREATE TABLE Products ( ProductCode nchar(6) not null, DateAcquired date DEFAULT GETDATE(), Name nvarchar(50), Size nvarchar(32), UnitPrice money, DiscountRate decimal(4, 2), CONSTRAINT PK_Products PRIMARY KEY(ProductCode) ); GO INSERT Products(ProductCode, Name, Size, UnitPrice) VALUES(N'274978', N'Mid Lady Bag - Lizard', N'14', 228), (N'827480', N'Midnight Floral Cardigan', N'12', 78), (N'183518', N'Zip Front Sheath Dress', N'Small', 138), (N'384680', N'Holly Gladiator Heel Shoes', N'7.5', 198), (N'247008', N'Short Black Skirt', N'Medium', 55.85); GO Now he wants to copy all the records and put them in a new table named Sales. What code can he use to do that? . SELECT FROM Products INTO Sales; a. GO b. COPY * FROM Products INTO Sales; c. GO d. GET ALL * INTO Sales FROM Products; e. GO f. WITH Products SELECT * INTO Sales; g. GO h. SELECT ALL * INTO Sales FROM Products; i. GO Adekunle has a table named Departments and another table named Employees. They were created and filled as follows: CREATE TABLE Departments ( DepartmentCode nchar(6) not null primary key, DepartmentName nvarchar(50) not null ); GO INSERT INTO Departments VALUES(N'HMRS', N'Human Resources'), (N'ACNT', N'Accounting'), (N'PSNL', N'Personnel'), (N'RSDV', N'Research & Development'); GO CREATE TABLE Employees ( EmployeeNumber nchar(10) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), EmploymentStatus nvarchar(32), DepartmentCode nchar(6)

); GO INSERT INTO Employees VALUES(N'283-947', N'Timothy', N'White', N'Part Time', N'RSDV'), (N'572-384', N'Jeannette', N'Welch', N'Part Time', N'PSNL'), (N'279-242', N'Ann', N'Welch', N'Full Time', N'HMRS'), (N'495-728', N'Robert', N'Simms', N'Part Time', N'RSDV'), (N'382-505', N'Paula', N'Waters', N'Part Time', N'PSNL'), (N'958-057', N'Peter', N'Aut', N'Part Time', N'HMRS'), (N'268-046', N'Martine', N'Nyamoto', N'Part Time', N'ACNT'), (N'400-752', N'James', N'Palau', N'Full Time', N'HMRS'), (N'773-148', N'James', N'Larsen', N'Part Time', N'RSDV'); GO What code can Ade use to get a list of full-time employees from the human resources department? . SELECT * FROM Employees a. WHERE (EmploymentStatus = N'Full Time') AND (DepartmentCode = N'HMRS'); b. GO c. SELECT * FROM Employees d. WHERE (EmploymentStatus = N'Full Time') OR (DepartmentCode = N'HMRS'); e. GO f. WITH (EmploymentStatus = N'Full Time') OR (DepartmentCode = N'HMRS') g. SELECT * FROM Employees; h. GO i. WHERE (EmploymentStatus = N'Full Time') AND (DepartmentCode IN N'HMRS'); j. SELECT * FROM Employees k. GO l. WHERE (EmploymentStatus = N'Full Time') OR (DepartmentCode = N'HMRS'); m. SELECT * FROM Employees n. GO Daniel has a table named Departments and another table named Employees. They were created and filled as follows: CREATE TABLE Departments ( DepartmentCode nchar(6) not null primary key, DepartmentName nvarchar(50) not null ); GO INSERT INTO Departments VALUES(N'HMRS', N'Human Resources'), (N'ACNT', N'Accounting'), (N'PSNL', N'Personnel'), (N'RSDV', N'Research & Development'); GO CREATE TABLE Employees ( EmployeeNumber nchar(10) not null primary key, FirstName nvarchar(20), LastName nvarchar(20),

EmploymentStatus nvarchar(32), DepartmentCode nchar(6) ); GO INSERT INTO Employees VALUES(N'283-947', N'Timothy', N'White', N'Part Time', N'RSDV'), (N'572-384', N'Jeannette', N'Welch', N'Part Time', N'PSNL'), (N'279-242', N'Ann', N'Welch', N'Full Time', N'HMRS'), (N'495-728', N'Robert', N'Simms', N'Part Time', N'RSDV'), (N'382-505', N'Paula', N'Waters', N'Part Time', N'PSNL'), (N'958-057', N'Peter', N'Aut', N'Part Time', N'HMRS'), (N'268-046', N'Martine', N'Nyamoto', N'Part Time', N'ACNT'), (N'400-752', N'James', N'Palau', N'Full Time', N'HMRS'), (N'773-148', N'James', N'Larsen', N'Part Time', N'RSDV'); GO What code can he use to get a list of all part-time employees regardless of their departments and all employees of the the Personnel department regardless of their employment status? . SELECT * FROM Employees a. WHERE (EmploymentStatus = N'Part Time') AND (DepartmentCode = N'PSNL'); b. GO c. WHEN (EmploymentStatus = N'Part Time') AND (DepartmentCode = N'HMRS') d. SELECT * FROM Employees; e. GO f. SELECT * FROM Employees g. WHERE (EmploymentStatus = N'Part Time') OR (DepartmentCode = N'PSNL'); h. GO i. WHEN (EmploymentStatus = N'Part Time') OR (DepartmentCode IN N'HMRS'); j. SELECT * FROM Employees k. GO l. SELECT * FROM Employees m. WITH (EmploymentStatus = N'Part Time') AND (DepartmentCode = N'HMRS'); n. GO Daniel has a table named Departments and another table named Employees. They were created and filled as follows: CREATE TABLE Departments ( DepartmentCode nchar(6) not null primary key, DepartmentName nvarchar(50) not null ); GO INSERT INTO Departments VALUES(N'HMRS', N'Human Resources'), (N'ACNT', N'Accounting'), (N'PSNL', N'Personnel'), (N'RSDV', N'Research & Development'); GO CREATE TABLE Employees (

EmployeeNumber nchar(10) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), EmploymentStatus nvarchar(32), DepartmentCode nchar(6) ); GO INSERT INTO Employees VALUES(N'283-947', N'Timothy', N'White', N'Part Time', N'RSDV'), (N'572-384', N'Jeannette', N'Welch', N'Part Time', N'PSNL'), (N'279-242', N'Ann', N'Welch', N'Full Time', N'HMRS'), (N'495-728', N'Robert', N'Simms', N'Part Time', N'RSDV'), (N'382-505', N'Paula', N'Waters', N'Part Time', N'PSNL'), (N'958-057', N'Peter', N'Aut', N'Part Time', N'HMRS'), (N'268-046', N'Martine', N'Nyamoto', N'Part Time', N'ACNT'), (N'400-752', N'James', N'Palau', N'Full Time', N'HMRS'), (N'773-148', N'James', N'Larsen', N'Part Time', N'RSDV'), (N'208-255', N'William', N'Aula', N'Full Time', N'PSNL'); GO He wants to get a list of part-time employees whose last name start with w. What code can he write to get that list? . SELECT * FROM Employees a. WHERE (EmploymentStatus = N'Part Time') OR (LastName LIKE N'w%'); b. GO c. WHEN (EmploymentStatus = N'Part Time') AND (LastName LIKE N'w%') d. SELECT * FROM Employees; e. GO f. WHEN (EmploymentStatus = N'Part Time') OR (LastName LIKE N'w%'); g. SELECT * FROM Employees h. GO i. SELECT * FROM Employees j. WHERE (EmploymentStatus = N'Part Time') AND (LastName LIKE N'w%'); k. GO l. SELECT * FROM Employees m. WITH (EmploymentStatus = N'Part Time') AND (LastName LIKE N'w%'); n. GO Daniel has a table named Departments and another table named Employees. They were created and filled as follows: CREATE TABLE Departments ( DepartmentCode nchar(6) not null primary key, DepartmentName nvarchar(50) not null ); GO INSERT INTO Departments VALUES(N'HMRS', N'Human Resources'), (N'ACNT', N'Accounting'), (N'PSNL', N'Personnel'), (N'RSDV', N'Research & Development'); GO CREATE TABLE Employees ( EmployeeNumber nchar(10) not null primary key,

FirstName nvarchar(20), LastName nvarchar(20), EmploymentStatus nvarchar(32), DepartmentCode nchar(6) ); GO INSERT INTO Employees VALUES(N'283-947', N'Timothy', N'White', N'Part Time', N'RSDV'), (N'572-384', N'Jeannette', N'Welch', N'Part Time', N'PSNL'), (N'279-242', N'Ann', N'Welch', N'Full Time', N'HMRS'), (N'495-728', N'Robert', N'Simms', N'Part Time', N'RSDV'), (N'382-505', N'Paula', N'Waters', N'Part Time', N'PSNL'), (N'958-057', N'Peter', N'Aut', N'Part Time', N'HMRS'), (N'268-046', N'Martine', N'Nyamoto', N'Part Time', N'ACNT'), (N'400-752', N'James', N'Palau', N'Full Time', N'HMRS'), (N'773-148', N'James', N'Larsen', N'Part Time', N'RSDV'), (N'208-255', N'William', N'Aula', N'Full Time', N'PSNL'); GO He wants to get a list of full-time employees of the human resources department and the part time employees of the personnel department. What code can he use to get that result? . SELECT * FROM Employees a. WHERE ((EmploymentStatus = N'Full Time') OR (DepartmentCode = N'HMRS')) b. AND c. ((EmploymentStatus = N'Part Time') OR (DepartmentCode = N'PSNL')); d. GO e. SELECT * FROM Employees f. WHERE ((EmploymentStatus = N'Full Time') AND (DepartmentCode = N'HMRS')) g. OR h. ((EmploymentStatus = N'Part Time') AND (DepartmentCode = N'PSNL')); i. GO j. SELECT * FROM Employees k. WHERE ((EmploymentStatus = N'Full Time') AND (DepartmentCode = N'HMRS')) l. WITH m. ((EmploymentStatus = N'Part Time') AND (DepartmentCode = N'PSNL')); n. GO o. SELECT * FROM Employees p. WHERE ((EmploymentStatus = N'Full Time') OR (DepartmentCode = N'HMRS')) q. OR r. ((EmploymentStatus = N'Part Time') OR (DepartmentCode = N'PSNL')); s. GO t. SELECT * FROM Employees u. WHERE ((EmploymentStatus = N'Full Time') AND (DepartmentCode = N'HMRS')) v. AND w. ((EmploymentStatus = N'Part Time') AND (DepartmentCode = N'PSNL')); x. GO

Joel has to create a table to hold employees records. The columns must be defined as follows Column Name EmployeeID FirstName LastName EmploymentStatus Data Type int nvarchar nvarchar nvarchar 20 20 32 Size

The values of the employment status column must be restristed to Part Time, Full Time, or Unknown. Any other value must be excluded. How can Joel write code to create that table? . a. b. c. d. e. f. g. h. i. j. k. l. m. n. o. CREATE TABLE Employees ( EmployeeID int unique, FirstName nvarchar(20), LastName nvarchar(20), EmploymentStatus nvarchar(32) SET EmploymentStatus(N'Full Time', N'Part Time', N'Unknown') ); GO CREATE TABLE Employees ( EmployeeID int unique, FirstName nvarchar(20), LastName nvarchar(20), EmploymentStatus nvarchar(32) )WITH EmploymentStatus AS (N'Full Time', N'Part Time', N'Unknown'); p. GO q. r. CREATE TABLE Employees s. ( t. EmployeeID int unique, u. FirstName nvarchar(20), v. LastName nvarchar(20), w. EmploymentStatus nvarchar(32), x. CONSTRAINT FOR EmploymentStatus IN(N'Full Time', N'Part Time', N'Unknown')) y. ); z. GO aa. CREATE TABLE Employees bb. ( cc. EmployeeID int unique, dd. FirstName nvarchar(20), ee. LastName nvarchar(20), ff. EmploymentStatus nvarchar(32) SET AS (N'Full Time', N'Part Time', N'Unknown') gg. ); hh. GO ii. CREATE TABLE Employees jj. ( kk. EmployeeID int unique,

ll. FirstName nvarchar(20), mm. LastName nvarchar(20), nn. EmploymentStatus nvarchar(32) oo. CHECK(EmploymentStatus IN(N'Full Time', N'Part Time', N'Unknown')) pp. ); qq. GO Kellie created a table named Employees and filled it up with some records as follows: CREATE TABLE Employees ( EmployeeID int unique, FirstName nvarchar(20), LastName nvarchar(20), EmploymentStatus nvarchar(32) CHECK(EmploymentStatus IN(N'Full Time', N'Part Time', N'Unknown')) ); GO INSERT INTO Employees VALUES(10, N'Timothy', N'White', N'Part Time'), (50, N'Jeannette', N'Welch', N'Part Time'), (36, N'Ann', N'Welch', N'Full Time'), (60, N'Robert', N'Simms', N'Part Time'), (20, N'Paula', N'Waters', N'Part Time'), (80, N'Peter', N'Aut', N'Part Time'), (30, N'Martine', N'Nyamoto', N'Part Time'), (24, N'James', N'Palau', N'Full Time'), (53, N'James', N'Larsen', N'Part Time'), (15, N'William', N'Aula', N'Full Time'); GO Now he wants to get a list of employees using their IDs from 20 to 40. What statement can help him get that result? . SELECT * FROM Employees a. WHERE EmployeeID BETWEEN 20 AND 40; b. GO c. SELECT * FROM Employees d. WHERE EmployeeID IN(20, 40); e. GO f. SELECT * FROM Employees g. WHERE (EmployeeID >= 20) AND (EmployeeID >= 40); h. GO i. SELECT * FROM Employees j. WHERE EmployeeID IN (20 TO 40); k. GO l. SELECT * FROM Employees m. WHERE EmployeeID FROM 20 TO 40; n. GO Sanko has a table of empoyees created as follows: CREATE TABLE Employees ( EmployeeNumber nchar(6) not null primary key, FirstName nvarchar(20), LastName nvarchar(20) not null );

GO He wants to create another table named Sales that has a column named EmployeeNumber whose values would come from the EmployeeNumber of the Employees table. To prevent people from breaking the relationships among records, he wants to make sure that when a record is deleted from the Employees table, the database engine would display an error. How must he create the new table? . CREATE TABLE Sales a. ( b. SaleCode nchar(10) not null primary key, c. SaleDate date not null, d. EmployeeNumber nchar(6) e. CONSTRAINT FK_Employees FOREIGN KEY f. REFERENCES Employees(EmployeeNumber), g. Amount money h. )ON DELETE CASCADE ERROR; i. GO j. CREATE TABLE Sales k. ( l. SaleCode nchar(10) not null primary key, m. SaleDate date not null, n. EmployeeNumber nchar(6) FOREIGN KEY o. REFERENCES Employees(EmployeeNumber), p. Amount money q. )ON DELETE SET NULL; r. GO s. CREATE TABLE Sales t. ( u. SaleCode nchar(10) not null primary key, v. SaleDate date not null, w. EmployeeNumber nchar(6) x. CONSTRAINT FK_Employees FOREIGN KEY y. REFERENCES Employees(EmployeeNumber) z. ON DELETE NO ACTION, aa. Amount money bb. ); cc. CREATE TABLE Sales dd. ( ee. SaleCode nchar(10) not null primary key, ff. SaleDate date not null, gg. EmployeeNumber nchar(6) FOREIGN KEY hh. REFERENCES Employees(EmployeeNumber) ii. ON DELETE SHOW ERROR, jj. Amount money kk. ); ll. GO mm. CREATE TABLE Sales nn. ( oo. SaleCode nchar(10) not null primary key, pp. SaleDate date not null, qq. EmployeeNumber nchar(6) FOREIGN KEY rr. REFERENCES Employees(EmployeeNumber), ss. Amount money tt. ); uu. WITH DELETE SET REFERENCE ERROR vv. GO July has a table of employees as follows:

CREATE TABLE Employees ( EmployeeNumber nchar(6) not null primary key, FirstName nvarchar(20), LastName nvarchar(20) not null ); GO Now she is creating a Products table that will contain a column that uses some values from the employees table. If a record of the Employees table is updated, she wants to display an error. How should she create the Products table? . CREATE TABLE Products a. ( b. ProductCode nchar(8) primary key, c. EmployeeNumber nchar(6) FOREIGN KEY REFERENCES Employees(EmployeeNumber) d. ON UPDATE SHOW ERROR, e. DateAcquired date, f. Name nvarchar(60), g. UnitPrice money h. ); i. GO j. CREATE TABLE Products k. ( l. ProductCode nchar(8) primary key, m. EmployeeNumber nchar(6) FOREIGN KEY REFERENCES Employees(EmployeeNumber), n. DateAcquired date, o. Name nvarchar(60), p. UnitPrice money q. )ON UPDATE CASCADE ERROR; r. GO s. DROP TABLE Products; t. GO u. CREATE TABLE Products v. ( w. ProductCode nchar(9) primary key, x. EmployeeNumber nchar(6) FOREIGN KEY REFERENCES Employees(EmployeeNumber) y. ON UPDATE SET NULL, z. DateAcquired date, aa. Name nvarchar(60), bb. UnitPrice money cc. ); dd. GO ee. CREATE TABLE Products ff. ( gg. ProductCode nchar(9) primary key, hh. EmployeeNumber nchar(6) FOREIGN KEY REFERENCES Employees(EmployeeNumber) ii. ON UPDATE NO ACTION, jj. DateAcquired date, kk. Name nvarchar(60), ll. UnitPrice money mm. ); nn. GO oo. CREATE TABLE Products

pp. ( qq. ProductCode nchar(9) primary key, rr. EmployeeNumber nchar(6) FOREIGN KEY REFERENCES Employees(EmployeeNumber), ss. DateAcquired date, tt. Name nvarchar(60), uu. UnitPrice money vv. )ON UPDATE SET ERROR; ww. GO John is creating a new table named Products after creating an Employees table as follows: CREATE TABLE Employees ( EmployeeNumber nchar(6) not null primary key, FirstName nvarchar(20), LastName nvarchar(20) not null ); GO He wants to make sure that when a record is deleted from the Employees table, any record of the Products table that was using the correspoding value of the Employees table is deleted. What code can he use to create the Products table? . CREATE TABLE Products a. ( b. ProductCode nchar(9) primary key, c. EmployeeNumber nchar(6) FOREIGN KEY REFERENCES Employees(EmployeeNumber), d. DateAcquired date, e. Name nvarchar(60), f. UnitPrice money g. )ON DELETE SET DELETE; h. GO i. CREATE TABLE Products j. ( k. ProductCode nchar(9) primary key, l. EmployeeNumber nchar(6) FOREIGN KEY REFERENCES Employees(EmployeeNumber) m. ON DELETE CASCADE, n. DateAcquired date, o. Name nvarchar(60), p. UnitPrice money q. ); r. GO s. CREATE TABLE Products t. ( u. ProductCode nchar(9) primary key, v. EmployeeNumber nchar(6) FOREIGN KEY REFERENCES Employees(EmployeeNumber), w. DateAcquired date, x. Name nvarchar(60), y. UnitPrice money z. )ON DELETE NO ACTION; aa. GO bb. CREATE TABLE Products cc. ( dd. ProductCode nchar(9) primary key,

ee. EmployeeNumber nchar(6) FOREIGN KEY REFERENCES Employees(EmployeeNumber) ff. ON DELETE SET NULL, gg. DateAcquired date, hh. Name nvarchar(60), ii. UnitPrice money jj. ); kk. GO ll. CREATE TABLE Products mm. ( nn. ProductCode nchar(9) primary key, oo. EmployeeNumber nchar(6) FOREIGN KEY REFERENCES Employees(EmployeeNumber), pp. DateAcquired date, qq. Name nvarchar(60), rr. UnitPrice money ss. )ON DELETE SET NULL; tt. GO Gio has a table that holds the types of houses in a database he created for a customer. The table was structured as follows: CREATE TABLE Categories ( CategoryID nchar(4) not null PRIMARY KEY, Category nvarchar(32) not null ); GO Gio now has to create a new table for the houses. The table must include a column that will get the house types for the above table. If a category is changed from the above table, Gio would like the records that were using that category in the new table to be changed to reflect the new value. How should he create the new table? . CREATE TABLE Houses a. ( b. Code nchar(11) not null PRIMARY KEY, c. CategoryID nchar(4) d. FOREIGN KEY REFERENCES Categories(CategoryID) e. ON UPDATE SET DELETE, f. City nvarchar(40), g. MarketValue money h. ); i. GO j. CREATE TABLE Houses k. ( l. Code nchar(11) not null PRIMARY KEY, m. CategoryID nchar(4) n. FOREIGN KEY REFERENCES Categories(CategoryID) o. ON UPDATE CASCADE, p. City nvarchar(40), q. MarketValue money r. ); s. GO t. CREATE TABLE Houses u. ( v. Code nchar(11) not null PRIMARY KEY, w. CategoryID nchar(4) x. FOREIGN KEY REFERENCES Categories(CategoryID),

y. z. aa. bb. cc. dd. ee. ff. gg. hh. ii. jj. kk. ll. mm. nn. oo. pp. qq. rr. ss. tt. uu.

City nvarchar(40), MarketValue money )ON UPDATE NO ACTION; GO CREATE TABLE Houses ( Code nchar(11) not null PRIMARY KEY, CategoryID nchar(4) FOREIGN KEY REFERENCES Categories(CategoryID) ON UPDATE SET NULL, City nvarchar(40), MarketValue money ); GO CREATE TABLE Houses ( Code nchar(11) not null PRIMARY KEY, CategoryID nchar(4) FOREIGN KEY REFERENCES Categories(CategoryID), City nvarchar(40), MarketValue money )ON UPDATE NULL; GO

Charlie is creating a real estate database for a new customer. He has already created a table for house types as follows: CREATE TABLE HouseTypes ( HouseTypeID int not null PRIMARY KEY, HouseType nvarchar(32) not null ); GO Now he has to create a table that holds the properties the company sells. The table of properties will have a column that specifies the type of house. The value of that column will come from the above table. When a house type deleted from the first table, Charlie wants the corresponding records of the new table to be changed to NULL. How can he create the new table to implement that functionality? . CREATE TABLE Properties a. ( b. PropertyNumber nchar(11) not null PRIMARY KEY, c. HouseTypeID int CONSTRAINT FK_PropTypes FOREIGN KEY d. REFERENCES HouseTypes(HouseTypeID) e. ON DELETE CASCADE NULL, f. City nvarchar(40), g. MarketValue money h. ); i. GO j. CREATE TABLE Properties k. ( l. PropertyNumber nchar(11) not null PRIMARY KEY, m. HouseTypeID int CONSTRAINT FK_PropTypes FOREIGN KEY n. REFERENCES HouseTypes(HouseTypeID) o. ON DELETE NO ACTION, p. City nvarchar(40), q. MarketValue money r. );

s. GO t. CREATE TABLE Properties u. ( v. PropertyNumber nchar(11) not null PRIMARY KEY, w. HouseTypeID int CONSTRAINT FK_PropTypes FOREIGN KEY x. REFERENCES HouseTypes(HouseTypeID), y. City nvarchar(40), z. MarketValue money aa. )ON DELETE NULL IS TRUE; bb. GO cc. CREATE TABLE Properties dd. ( ee. PropertyNumber nchar(11) not null PRIMARY KEY, ff. HouseTypeID int CONSTRAINT FK_PropTypes FOREIGN KEY gg. REFERENCES HouseTypes(HouseTypeID) hh. ON DELETE SET NULL, ii. City nvarchar(40), jj. MarketValue money kk. ); ll. GO mm. CREATE TABLE Properties nn. ( oo. PropertyNumber nchar(11) not null PRIMARY KEY, pp. HouseTypeID int CONSTRAINT FK_PropTypes FOREIGN KEY qq. REFERENCES HouseTypes(HouseTypeID), rr. City nvarchar(40), ss. MarketValue money tt. )ON DELETE SET CASCADE NULL; uu. GO Courtney is creating a database for a community organization. The datable will have a table of members where each record is represented by a membership category. To limit the number of categories, Courney first creates a table of membership categories as follows: CREATE TABLE Categories ( CategoryID int not null PRIMARY KEY, Category nvarchar(32) not null ); GO In the table for members, since Courtney will include a column for the categories, when a record of the Categories table is are updated, she wants the corresponding field in the members table to receive a NULL value. How should she create the table for the members? . CREATE TABLE Members a. ( b. MemberID int unique, c. Name nvarchar(50), d. CategoryID int FOREIGN KEY REFERENCES Categories(CategoryID) e. ON UPDATE CASCADE NULL, f. MembershipStatus nvarchar(20) g. ); h. GO i. CREATE TABLE Members j. ( k. MemberID int unique,

l. Name nvarchar(50), m. CategoryID int FOREIGN KEY REFERENCES Categories(CategoryID) n. ON UPDATE NO ACTION, o. MembershipStatus nvarchar(20) p. ); q. GO r. CREATE TABLE Members s. ( t. MemberID int unique, u. Name nvarchar(50), v. CategoryID int FOREIGN KEY REFERENCES Categories(CategoryID) w. ON UPDATE SET NULL, x. MembershipStatus nvarchar(20) y. ); z. GO aa. CREATE TABLE Members bb. ( cc. MemberID int unique, dd. Name nvarchar(50), ee. CategoryID int FOREIGN KEY REFERENCES Categories(CategoryID), ff. MembershipStatus nvarchar(20) gg. )ON UPDATE NULL IS TRUE; hh. GO ii. CREATE TABLE Members jj. ( kk. MemberID int unique, ll. Name nvarchar(50), mm. CategoryID int FOREIGN KEY REFERENCES Categories(CategoryID), nn. MembershipStatus nvarchar(20) oo. )ON UPDATE SET NULL; pp. GO Douglas is creating a database for his company to manage employees records. One of the details about each employee will be the employment status. Douglas creates a table for employment status as follows: CREATE TABLE EmploymentTypes ( EmploymentTypeID int identity(1000, 10) primary key, EmploymenStatus nvarchar(20) not null, ); GO INSERT INTO EmploymentTypes(EmploymenStatus) VALUES(N'Full Time'),(N'Part Time'),(N'Unknown'); GO To keep track of employees, Douglas starts creating a table as follows: CREATE TABLE Employees ( EmployeeNumber nchar(6) not null primary key, EmploymentTypeID int FOREIGN KEY REFERENCES EmploymentTypes(EmploymentTypeID) DEFAULT 3, FirstName nvarchar(20), LastName nvarchar(20) not null, HourlySalary money

); GO If an employment status is deleted from the EmploymentStatus table, Douglas would like the employees who use that status to get the default value. How should he change the Employees table to take care of this requirement? . CREATE TABLE Employees a. ( b. EmployeeNumber nchar(6) not null primary key, c. EmploymentTypeID int FOREIGN KEY d. REFERENCES EmploymentTypes(EmploymentTypeID) e. ON DELETE SET DEFAULT f. DEFAULT 3, g. FirstName nvarchar(20), h. LastName nvarchar(20) not null, i. HourlySalary money j. ); k. GO l. CREATE TABLE Employees m. ( n. EmployeeNumber nchar(6) not null primary key, o. EmploymentTypeID int FOREIGN KEY p. REFERENCES EmploymentTypes(EmploymentTypeID) q. DEFAULT 3, r. FirstName nvarchar(20), s. LastName nvarchar(20) not null, t. HourlySalary money u. )ON DELETE DEFAULT = NULL; v. GO w. CREATE TABLE Employees x. ( y. EmployeeNumber nchar(6) not null primary key, z. EmploymentTypeID int FOREIGN KEY aa. REFERENCES EmploymentTypes(EmploymentTypeID) bb. DEFAULT 3 cc. ON DELETE CASCADE DEFAULT, dd. FirstName nvarchar(20), ee. LastName nvarchar(20) not null, ff. HourlySalary money gg. ); hh. GO ii. CREATE TABLE Employees jj. ( kk. EmployeeNumber nchar(6) not null primary key, ll. EmploymentTypeID int FOREIGN KEY mm. REFERENCES EmploymentTypes(EmploymentTypeID) nn. ON DELETE NO ACTION oo. DEFAULT 3, pp. FirstName nvarchar(20), qq. LastName nvarchar(20) not null, rr. HourlySalary money ss. ); tt. GO uu. CREATE TABLE Employees vv. ( ww. EmployeeNumber nchar(6) not null primary key, xx. EmploymentTypeID int FOREIGN KEY

yy. zz. aaa. bbb. ccc. ddd. eee.

REFERENCES EmploymentTypes(EmploymentTypeID) DEFAULT 3, FirstName nvarchar(20), LastName nvarchar(20) not null, HourlySalary money )ON DELETE DEFAULT IS TRUE; GO

Joseph is working on a database for a department store. He creates a table for the categories of items sold in the store: CREATE TABLE ItemsTypes ( ItemTypeID int identity(1, 1) primary key, ItemType nvarchar(20) not null, ); GO INSERT INTO ItemsTypes(ItemType) VALUES(N'Miscellaneous'),(N'Shirts'),(N'Dresses'),(N'Pants'); GO In the table of items, there will be a column that gets its values from the ItemsTypes table. To start with the items sold in the store, Josephs write the following code without executing it: CREATE TABLE StoreItems ( ItemCode nchar(10) not null primary key, ItemTypeID int FOREIGN KEY REFERENCES ItemsTypes(ItemTypeID) DEFAULT 1, Name nvarchar(50), Size nvarchar(20) not null, UnitPrice money ); GO Sometimes the employees will change the name of a type in the ItemsTypes table. When this happens, Joseph wants the items that use that category to get the default value. How can Joseph change the code the StoreItems table to take care of this? . CREATE TABLE StoreItems a. ( b. ItemCode nchar(10) not null primary key, c. ItemTypeID int FOREIGN KEY d. REFERENCES ItemsTypes(ItemTypeID) e. DEFAULT 1, f. Name nvarchar(50), g. Size nvarchar(20) not null, h. UnitPrice money i. ) ON UPDATE DEFAULT = NULL; j. GO k. CREATE TABLE StoreItems l. ( m. ItemCode nchar(10) not null primary key, n. ItemTypeID int FOREIGN KEY o. REFERENCES ItemsTypes(ItemTypeID) p. ON UPDATE CASCADE DEFAULT q. DEFAULT 1, r. Name nvarchar(50), s. Size nvarchar(20) not null,

t. UnitPrice money u. ); v. GO w. CREATE TABLE StoreItems x. ( y. ItemCode nchar(10) not null primary key, z. ItemTypeID int FOREIGN KEY aa. REFERENCES ItemsTypes(ItemTypeID) bb. DEFAULT 1, cc. Name nvarchar(50), dd. Size nvarchar(20) not null, ee. UnitPrice money ff. )ON UPDATE NO ACTION; gg. GO hh. CREATE TABLE StoreItems ii. ( jj. ItemCode nchar(10) not null primary key, kk. ItemTypeID int FOREIGN KEY ll. REFERENCES ItemsTypes(ItemTypeID) mm. DEFAULT 1 nn. ON UPDATE DEFAULT IS TRUE, oo. Name nvarchar(50), pp. Size nvarchar(20) not null, qq. UnitPrice money rr. ); ss. GO tt. CREATE TABLE StoreItems uu. ( vv. ItemCode nchar(10) not null primary key, ww. ItemTypeID int FOREIGN KEY xx. REFERENCES ItemsTypes(ItemTypeID) yy. ON UPDATE SET DEFAULT zz. DEFAULT 1, aaa. Name nvarchar(50), bbb. Size nvarchar(20) not null, ccc. UnitPrice money ddd. ); eee. GO John has the following tables of employees and contractors who work for his company: CREATE TABLE Employees ( EmployeeNumber nchar(9), FirstName nvarchar(20), LastName nvarchar(20), HourlySalary money, [Status] nvarchar(20) default N'Employee' ); GO CREATE TABLE Contractors ( ContractorCode nchar(7), Name1 nvarchar(20), Name2 nvarchar(20), Wage decimal(6, 2),

[Type] nvarchar(20) default N'Contractor' ); GO INSERT INTO Employees(EmployeeNumber, FirstName, LastName, HourlySalary) VALUES(N'2930-4708', N'John', N'Franks', 20.05), (N'8274-9571', N'Peter', N'Sonnens', 10.65), (N'6359-8079', N'Leslie', N'Aronson', 15.88); GO INSERT INTO Contractors(ContractorCode, Name1, Name2, Wage) VALUES(N'350-809', N'Mary', N'Shamberg', 14.20), (N'286-606', N'Chryssa', N'Lurie', 20.26); GO In preparation of payroll, John wants to preview the employees and contractors in one common list. What code can he write to get that list? . a. b. c. d. e. f. g. h. i. j. k. l. m. n. o. p. q. r. He can't because some data types in the tables are not compatible SELECT * FROM GO SELECT * FROM GO SELECT * FROM UNION SELECT * FROM GO SELECT * FROM GO UNION SELECT * FROM GO WITH UNION SELECT * FROM AND SELECT * FROM GO Employees; Contractors; Employees Contractors; Employees; Contractors; Employees Contractors;

Marc has the following tables of seasonal employees and contractors who do side jobs for his company: CREATE TABLE Seasonals ( Number nchar(9), FName nvarchar(20), LName nvarchar(20), HourlySalary money ); GO CREATE TABLE Contractors ( Code nchar(7), Name1 nvarchar(20), Name2 nvarchar(20), Wage decimal(6, 2) ); GO

INSERT INTO Seasonals VALUES(N'2930-4708', N'John', N'Franks', 20.05), (N'8274-9571', N'Peter', N'Sonnens', 10.65), (N'6359-8079', N'Leslie', N'Aronson', 15.88); GO INSERT INTO Contractors VALUES(N'350-809', N'Mary', N'Shamberg', 14.20), (N'286-606', N'Chryssa', N'Lurie', 20.26); GO All these seasonal employees and contractors have been hired by the company. To prepare their inclusion into the company, Mark creates a new table named Employees as follows: CREATE TABLE Employees ( EmployeeNumber nchar(9), FirstName nvarchar(20), LastName nvarchar(20), HourlySalary money ); GO Marc wants to add the seasonal employees and the contractors to the Employees table. What code can let him do that? . SELECT FROM Seasonals INTO Employees a. UNION b. SELECT FROM Contractors INTO Employees; c. GO d. INSERT INTO Employees e. SELECT * FROM Seasonals f. UNION g. SELECT * FROM Contractors; h. GO i. UNION ALL j. SELECT ALL * FROM Seasonals k. AND l. SELECT ALL * FROM Contractors m. INTO Employees; n. GO o. SELECT ALL * FROM Seasonals p. AND q. SELECT ALL * FROM Contractors r. INTO Employees s. UNION ALL; t. GO u. SELECT ALL * FROM Seasonals, Contractors v. INTO Employees w. UNION ALL; x. GO George has the following tables with records: CREATE TABLE Contractors ( ContractorCode nchar(10), FName nvarchar(20), LName nvarchar(20), Wage decimal(6, 2) );

GO CREATE TABLE Employees ( EmployeeNumber nchar(10), DateHired date, FirstName nvarchar(20), LastName nvarchar(20), HourlySalary money, EmploymentStatus nvarchar(20) null ); GO INSERT INTO Contractors VALUES(N'35080', N'Mary', N'Shamberg', 14.20), (N'286606', N'Chryssa', N'Lurie', 20.26), (N'415905', N'Ralph', N'Sunny', 15.55); GO INSERT INTO Employees VALUES(N'286018', N'20020426', N'Julie', N'Chance', 12.84, N'Full Time'), (N'286606', N'19981008', N'Ayinda', N'Kaihibu', 9.52, N'Part Time'), (N'922620', N'20100815', N'Ann', N'Keans', 20.52, N'Full Time'), (N'415905', N'20061222', N'Godwin', N'Harrison', 18.75, N'Full Time'), (N'682470', N'20080430', N'Timothy', N'Journ', 21.05, NULL); GO He wants to merge the records to add those of the contractors to the Employees table by comparing the employee numbers to the contractors codes. During the operation, if a record from the Contractors table matches an employee number, two leading 0s will be added to the employeee number to make sure the numbers remain unique (but the other parts of the record will not be changed). Otherwise, the record should be added. What code would accomplish this? . USING Contractors AS SOURCE a. MERGE Employees AS TARGET b. ON (Workers.ContractorCode = Teachers.EmployeeNumber) c. WHEN MATCHED d. THEN UPDATE SET EmployeeNumber = N'00' + ContractorCode e. WHEN NOT MATCHED BY SOURCE f. THEN INSERT(EmployeeNumber, FirstName, LastName, HourlySalary) g. VALUES(ContractorCode, FName, LName, Wage); h. GO i. USING Contractors AS SOURCE j. MERGE Employees AS TARGET k. ON (Workers.ContractorCode = Teachers.EmployeeNumber) l. WHEN NOT MATCHED BY SOURCE m. THEN INSERT(EmployeeNumber, FirstName, LastName, HourlySalary) n. VALUES(ContractorCode, FName, LName, Wage) o. WHEN MATCHED p. THEN UPDATE SET EmployeeNumber = N'00' + ContractorCode; q. GO r. MERGE Employees AS Teachers s. WHEN MATCHED t. THEN UPDATE SET EmployeeNumber = N'00' + ContractorCode u. WHEN NOT MATCHED BY SOURCE

v.

THEN INSERT(EmployeeNumber, FirstName, LastName, HourlySalary) w. VALUES(ContractorCode, FName, LName, Wage) x. USING Contractors AS Workers y. ON (Workers.ContractorCode = Teachers.EmployeeNumber); z. MERGE Employees AS Teachers aa. USING Contractors AS Workers bb. ON (Workers.ContractorCode = Teachers.EmployeeNumber) cc. WHEN MATCHED dd. THEN UPDATE SET EmployeeNumber = N'00' + ContractorCode ee. WHEN NOT MATCHED BY TARGET ff. THEN INSERT(EmployeeNumber, FirstName, LastName, HourlySalary) gg. VALUES(ContractorCode, FName, LName, Wage); hh. GO ii. WITH MERGE Employees AS Teachers jj. ON (Workers.ContractorCode = Teachers.EmployeeNumber) kk. USING Contractors AS Workers ll. WHEN MATCHED mm. THEN UPDATE SET EmployeeNumber = N'00' + ContractorCode nn. WHEN NOT MATCHED BY SOURCE oo. THEN INSERT(EmployeeNumber, FirstName, LastName, HourlySalary) pp. VALUES(ContractorCode, FName, LName, Wage); qq. GO While working for a department store, Evelyne receives two tables that contain lists of items sold in the store. The tables were created as follows: CREATE TABLE Products ( ProductNumber int not null, DateAcquired date, Name nvarchar(50), Size nvarchar(32), UnitPrice money, CONSTRAINT PK_Products PRIMARY KEY(ProductNumber) ); GO CREATE TABLE StoreItems ( ItemCode int identity(1, 1) not null PRIMARY KEY, Arrival date, [Description] nvarchar(50), Value money ); GO INSERT Products VALUES(2, N'2011-12-06', N'Mid Lady Bag - Lizard', N'12', 228), (888, N'2010-08-09', N'Midnight Floral Cardigan', N'Small', 78), (105583, N'2011-10-12', N'Zip Front Sheath Dress', N'8', 138), (4, N'2010-05-24', N'Holly Gladiator Heel Shoes', N'7.5', 198), (3680, N'2011-02-16', N'Short Black Skirt', N'14', 55.85), (28, NULL, N'Color-Block Chambray Shirt', N'10', 85.25); GO INSERT StoreItems(Arrival, [Description], Value) VALUES(N'2010-02-22', N'Short-Sleeved Bush Shirt', 59.95),

(N'2011-10-12', N'Zip Front Sheath Dress', 138), (N'2010-05-24', N'Pure Cashmere Sweater', 165), (N'2011-02-16', N'Short Black Skirt', 55.85); GO It appears that some records are duplicated. To start, Evelyne wants to merge the records from the StoreItems to the Products tables. During this operation, if a record from one table matches a record from the other table, the matching record should be removed. Otherwise, if the record is not found in the StoreItems table, it should be added to the Products table. How can she write code to merge the records? . USING StoreItems AS Items a. MERGE Products AS Inventory b. ON Inventory.ProductNumber = Items.ItemCode c. WHEN MATCHED d. THEN DELETE e. WHEN NOT MATCHED THEN f. INSERT(ProductNumber, DateAcquired, Name, UnitPrice) g. VALUES(ItemCode, Arrival, [Description], Value); h. GO i. MERGE Products AS Inventory j. USING StoreItems AS Items k. ON Inventory.ProductNumber = Items.ItemCode l. WHEN MATCHED THEN DELETE m. WHEN NOT MATCHED THEN n. INSERT(ProductNumber, DateAcquired, Name, UnitPrice) o. VALUES(ItemCode, Arrival, [Description], Value); p. GO q. WITH StoreItems AS Items r. MERGE Products AS Inventory s. ON Inventory.ProductNumber = Items.ItemCode t. WHEN MATCHED u. THEN DELETE v. WHEN NOT MATCHED THEN w. INSERT(ProductNumber, DateAcquired, Name, UnitPrice) x. VALUES(ItemCode, Arrival, [Description], Value); y. GO z. WITH StoreItems AS Items aa. MERGE Products AS Inventory bb. ON Inventory.ProductNumber = Items.ItemCode cc. WHEN MATCHED SET NULL dd. OR ee. INSERT(ProductNumber, DateAcquired, Name, UnitPrice) ff. VALUES(ItemCode, Arrival, [Description], Value); gg. GO hh. SELECT * FROM Products AS Inventory ii. AND jj. SELECT * FROM StoreItems AS Items kk. MERGE ll. ON Inventory.ProductNumber = StoreItems.ItemCode mm. IF MATCH THEN nn. DELETE oo. ELSE pp. INSERT(ProductNumber, DateAcquired, Name, UnitPrice) qq. VALUES(ItemCode, Arrival, [Description], Value); rr. GO Imagine you have a table as follows:

CREATE TABLE Rooms ( RoomNumber nchar(10) not null, RoomType nvarchar(20) default N'Bedroom', BedType nvarchar(40) default N'Queen', Rate money default 75.85, Available bit ); GO INSERT INTO Rooms(RoomNumber, BedType, Rate, Available) VALUES(N'104', default, 80.25, 0), (N'105', N'King', 95.50, 1), (N'108', N'King', 92.50, 1), (N'109', default, 68.95, 0), (N'110', default, 74.95, 1); GO How can you write a common table expression to see its records? . WITH BedRooms AS a. ( b. SELECT * FROM Rooms c. ) d. e. SELECT * FROM BedRooms; f. GO g. WITH BedRooms AS SELECT * FROM BedRooms; h. BEGIN i. SELECT * FROM Rooms j. END k. SELECT * FROM BedRooms l. AS BedRooms m. BEGIN n. SELECT * FROM Rooms o. END p. WITH BedRooms q. AS r. BEGIN s. SELECT * FROM Rooms t. END u. SELECT * FROM Rooms AS BedRooms v. BEGIN w. SELECT * FROM Bedrooms x. END Imagine you have a table as follows: CREATE TABLE Rooms ( RoomNumber nchar(10) not null, RoomType nvarchar(20) default N'Bedroom', BedType nvarchar(40) default N'Queen', Rate money default 75.85, Available bit ); GO INSERT INTO Rooms(RoomNumber, BedType, Rate, Available) VALUES(N'104', default, 80.25, 0), (N'105', N'King', 95.50, 1),

(N'108', N'King', 92.50, 1), (N'109', default, 68.95, 0), (N'110', default, 74.95, 1); GO What code allows you to create a common table expression that includes only King bedrooms? . CREATE BedRooms(RoomNumber, RoomType, BedType, Rate, Available) a. AS CTE b. BEGIN c. SELECT RoomNumber, RoomType, BedType, Rate, Available d. FROM Rooms e. WHERE BedType = N'King' f. END g. SELECT RoomNumber, RoomType, Rate, Available FROM BedRooms h. GO i. SELECT RoomNumber, RoomType, BedType, Rate, Available j. FROM Rooms k. WHERE BedType = N'King' l. AS BedRooms(RoomNumber, RoomType, BedType, Rate, Available); m. GO n. SELECT RoomNumber, RoomType, Rate, Available FROM BedRooms o. GO p. WITH BedRooms(RoomNumber, RoomType, BedType, Rate, Available) q. AS r. ( s. SELECT RoomNumber, RoomType, BedType, Rate, Available t. FROM Rooms u. WHERE BedType = N'King' v. ) w. SELECT RoomNumber, RoomType, Rate, Available FROM BedRooms x. GO y. SET BedRooms(RoomNumber, RoomType, BedType, Rate, Available) z. BEGIN aa. SELECT RoomNumber, RoomType, BedType, Rate, Available bb. FROM Rooms cc. WHERE BedType = N'King' dd. END ee. SELECT RoomNumber, RoomType, Rate, Available FROM BedRooms ff. GO gg. WITH BedRooms(RoomNumber, RoomType, BedType, Rate, Available) hh. BEGIN ii. SELECT RoomNumber, RoomType, BedType, Rate, Available jj. FROM Rooms kk. WHERE BedType = N'King' ll. SELECT RoomNumber, RoomType, Rate, Available FROM BedRooms mm. END nn. GO Lance is creating a database for a hotel. Based on papers provided by the customer, he created two tables as follows: CREATE TABLE SleepingRooms ( RoomNumber nchar(10) not null, RoomType nvarchar(20) default N'Bedroom', BedType nvarchar(40) default N'Queen', Rate money default 75.85, Available bit

); GO CREATE TABLE ConferenceRooms ( RoomNumber nchar(10) not null, RoomType nvarchar(20) default N'Conference', BedType nvarchar(40), Rate money default 75.85, Available bit ); GO INSERT INTO SleepingRooms(RoomNumber, BedType, Rate, Available) VALUES(N'104', default, 80.25, 0), (N'105', N'King', 95.50, 1), (N'108', N'King', 92.50, 1), (N'109', default, 68.95, 0), (N'110', default, 74.95, 1); GO INSERT INTO ConferenceRooms(RoomNumber, Rate) VALUES(N'C-120', 525.00), (N'C-122', 450.00); GO How can he create a common table expression to get a preview of bedrooms and conference rooms in one list? . WITH HotelRooms a. BEGIN b. SELECT * FROM SleepingRooms c. UNION d. SELECT * FROM ConferenceRooms e. END f. SELECT * FROM HotelRooms; g. GO h. SET CTE i. BEGIN j. SELECT * FROM SleepingRooms k. UNION l. SELECT * FROM ConferenceRooms m. END n. WITH HotelRooms o. SELECT * FROM HotelRooms; p. GO q. DECLARE @HotelRooms AS VIEW r. BEGIN s. SELECT * FROM SleepingRooms t. UNION u. SELECT * FROM ConferenceRooms v. END w. SELECT * FROM @HotelRooms; x. GO y. WITH HotelRooms AS TABLE z. BEGIN aa. SELECT * FROM SleepingRooms bb. UNION ALL cc. SELECT * FROM ConferenceRooms dd. END

ee. ff. gg. hh. ii. jj. kk. ll. mm. nn. oo.

SELECT * FROM @HotelRooms; GO WITH HotelRooms AS ( SELECT * FROM SleepingRooms UNION SELECT * FROM ConferenceRooms ) SELECT * FROM HotelRooms; GO

Lance is creating a database for a hotel. Based on papers provided by the customer, he created two tables as follows: CREATE TABLE SleepingRooms ( RoomNumber nchar(10) not null, RoomType nvarchar(20) default N'Bedroom', BedType nvarchar(40) default N'Queen', Rate money default 75.85, Available bit ); GO CREATE TABLE ConferenceRooms ( RoomNumber nchar(10) not null, RoomType nvarchar(20) default N'Conference', BedType nvarchar(40), Rate money default 75.85, Available bit ); GO INSERT INTO SleepingRooms(RoomNumber, BedType, Rate, Available) VALUES(N'104', default, 80.25, 0), (N'105', N'King', 95.50, 1), (N'108', N'King', 92.50, 1), (N'109', default, 68.95, 0), (N'110', default, 74.95, 1); GO INSERT INTO ConferenceRooms(RoomNumber, Rate) VALUES(N'C-120', 525.00), (N'C-122', 450.00); GO How can he create a common table expression that shows a list available bedrooms and conference rooms? . SET HotelRooms a. BEGIN b. SELECT * FROM SleepingRooms c. UNION d. SELECT * FROM ConferenceRooms e. END f. SELECT RoomNumber, RoomType, BedType, Rate g. FROM HotelRooms

h. WHERE Available = 1; i. GO j. WITH HotelRooms k. AS l. ( m. SELECT * FROM SleepingRooms n. UNION o. SELECT * FROM ConferenceRooms p. ) q. SELECT RoomNumber, RoomType, BedType, Rate r. FROM HotelRooms s. WHERE Available = 1; t. GO u. WITH HotelRooms v. BEGIN w. SELECT * FROM SleepingRooms x. UNION y. SELECT * FROM ConferenceRooms z. END aa. AS bb. SELECT RoomNumber, RoomType, BedType, Rate cc. FROM HotelRooms dd. WHERE Available = 1; ee. GO ff. WITH HotelRooms gg. MERGE AS hh. ( ii. SELECT * FROM SleepingRooms jj. UNION kk. SELECT * FROM ConferenceRooms ll. ) mm. SELECT RoomNumber, RoomType, BedType, Rate nn. FROM HotelRooms oo. WHERE Available = 1; pp. GO qq. WITH HotelRooms rr. MERGE AS ss. BEGIN tt. SELECT * FROM SleepingRooms uu. WHERE Available = 1 vv. UNION ww. SELECT * FROM ConferenceRooms xx. WHERE Available = 1 yy. END zz. SELECT RoomNumber, RoomType, BedType, Rate aaa. FROM HotelRooms; bbb. GO Consider the following table: CREATE TABLE Rooms ( RoomNumber nchar(10) not null, RoomType nvarchar(20) default N'Bedroom', BedType nvarchar(40) default N'Queen', Rate money default 75.85, Available bit );

GO INSERT INTO SleepingRooms(RoomNumber, BedType, Rate, Available) VALUES(N'104', default, 80.25, 0), (N'105', N'King', 95.50, 1), (N'108', N'King', 92.50, 1), (N'109', default, 68.95, 0), (N'110', default, 74.95, 1); GO Write an inline table-valued function that would produce all records of that table . CREATE FUNCTION GetRooms() AS TABLE a. RETURN b. SELECT ALL * FROM Rooms; c. GO d. CREATE FUNCTION GetRooms() e. RETURN f. SELECT ALL * FROM Rooms AS TABLE; g. GO h. CREATE FUNCTION GetRooms() i. RETURNS TABLE j. BEGIN k. SELECT ALL * FROM Rooms; l. END m. GO n. CREATE FUNCTION GetRooms() o. RETURNS TABLE p. AS q. RETURN SELECT ALL * FROM Rooms; r. GO s. CREATE FUNCTION GetRooms() t. BEGIN u. RETURN SELECT ALL * FROM Rooms; v. END w. GO While managing a furniture store, Elise has a table of employees and their sales as follows: CREATE SCHEMA Personnel; GO CREATE SCHEMA Commercial; GO CREATE TABLE Personnel.Employees ( EmployeeNumber nchar(7) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), EmploymentStatus smallint, HourlySalary money ); GO CREATE TABLE Commercial.Sales ( SaleID int identity(1, 1), EmployeeNumber nchar(7) not null, SaleDate date, Amount money

); GO INSERT Personnel.Employees VALUES(N'284-680', N'Anselme', N'Bongos', 2, 18.62), (N'730-704', N'June', N'Malea', 1, 9.95), (N'735-407', N'Frank', N'Monson', 3, 14.58), (N'281-730', N'Jerry', N'Beaulieu', 1, 16.65); GO INSERT INTO Commercial.Sales(EmployeeNumber, SaleDate, Amount) VALUES(N'284-680', N'2011-02-14', 4250), (N'735-407', N'2011-02-14', 5300), (N'730-704', N'2011-02-14', 2880), (N'281-730', N'2011-02-14', 4640), (N'284-680', N'2011-02-15', 4250), (N'281-730', N'2011-02-15', 3675); GO Instead of a view, she wants to create an inline table-valued function named GetSales that can produce a list of all sales made by the employees. Each record will include the employee's full name (the last name followed by a comma and followed by the first name), the date a sale was made, and the amount of the sale. How can she write code for that function? . CREATE FUNCTION GetSales() a. AS TABLE b. RETURN c. SELECT pe.LastName + N', ' + pe.FirstName, d. cs.SaleDate, cs.Amount e. FROM Commercial.Sales cs f. INNER JOIN Personnel.Employees pe g. ON cs.EmployeeNumber = pe.EmployeeNumber; h. GO i. CREATE FUNCTION GetSales() j. RETURN TABLE k. BEGIN l. RETURNS m. SELECT pe.LastName + N', ' + pe.FirstName AS [Full Name], n. cs.SaleDate, cs.Amount o. FROM Commercial.Sales cs p. INNER JOIN Personnel.Employees pe q. ON cs.EmployeeNumber = pe.EmployeeNumber; r. END s. GO t. CREATE INLINE FUNCTION GetSales() u. RETURN TABLE v. BEGIN w. SELECT pe.LastName + N', ' + pe.FirstName, x. cs.SaleDate, cs.Amount y. FROM Commercial.Sales cs z. INNER JOIN Personnel.Employees pe aa. ON cs.EmployeeNumber = pe.EmployeeNumber; bb. END cc. GO dd. CREATE FUNCTION GetSales() ee. RETURNS TABLE ff. AS gg. RETURN

hh. ii. jj. kk. ll. mm. nn. oo. pp. qq. rr. ss. tt. uu. vv. ww.

SELECT pe.LastName + N', ' + pe.FirstName AS [Full Name], cs.SaleDate, cs.Amount FROM Commercial.Sales cs INNER JOIN Personnel.Employees pe ON cs.EmployeeNumber = pe.EmployeeNumber; GO CREATE FUNCTION GetSales() BEGIN SELECT pe.LastName + N', ' + pe.FirstName AS [Full Name], cs.SaleDate, cs.Amount FROM Commercial.Sales cs INNER JOIN Personnel.Employees pe ON cs.EmployeeNumber = pe.EmployeeNumber; END RETURN TABLE GO

While managing a furniture store, Elise has a table of employees and their sales as follows: CREATE SCHEMA Personnel; GO CREATE SCHEMA Commercial; GO CREATE TABLE Personnel.Employees ( EmployeeNumber nchar(7) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), EmploymentStatus smallint, HourlySalary money ); GO INSERT Personnel.Employees VALUES(N'284-680', N'Anselme', N'Bongos', 2, 18.62), (N'730-704', N'June', N'Malea', 1, 9.95), (N'735-407', N'Frank', N'Monson', 3, 14.58), (N'281-730', N'Jerry', N'Beaulieu', 1, 16.65); GO CREATE TABLE Commercial.Sales ( SaleID int identity(1, 1), EmployeeNumber nchar(7) not null, SaleDate date, Amount money ); GO INSERT INTO Commercial.Sales(EmployeeNumber, SaleDate, Amount) VALUES(N'284-680', N'2011-02-14', 4250), (N'735-407', N'2011-02-14', 5300), (N'730-704', N'2011-02-14', 2880), (N'281-730', N'2011-02-14', 4640), (N'284-680', N'2011-02-15', 4250), (N'281-730', N'2011-02-15', 3675); GO

Since views don't allow parameterized queries, she wants to create an inline tablevalued function that takes an employee number as argument and produces the sales made by that employee. Each record will include the employee's full name (the last name followed by a comma and followed by the first name), the date a sale was made, and the amount of the sale. How can she write code to produce that result? . CREATE FUNCTION Commercial.GetSales(@EmplNbr nchar(7)) a. RETURNS TABLE b. AS c. RETURN d. SELECT pe.LastName + N', ' + pe.FirstName AS [Full Name], e. cs.SaleDate, cs.Amount f. FROM Commercial.Sales cs g. INNER JOIN Personnel.Employees pe h. ON cs.EmployeeNumber = pe.EmployeeNumber i. WHERE pe.EmployeeNumber = @EmplNbr; j. GO k. CREATE FUNCTION Commercial.GetSales(@EmplNbr nchar(7)) l. RETURN m. SELECT pe.LastName + N', ' + pe.FirstName AS [Full Name], n. cs.SaleDate, cs.Amount o. FROM Commercial.Sales cs p. INNER JOIN Personnel.Employees pe q. ON cs.EmployeeNumber = pe.EmployeeNumber r. WHERE pe.EmployeeNumber = @EmplNbr s. RETURNS TABLE t. END u. GO v. CREATE INLINE FUNCTION Commercial.GetSales(@EmplNbr nchar(7)) AS TABLE w. BEGIN x. SELECT pe.LastName + N', ' + pe.FirstName AS [Full Name], y. cs.SaleDate, cs.Amount z. FROM Commercial.Sales cs aa. INNER JOIN Personnel.Employees pe bb. ON cs.EmployeeNumber = pe.EmployeeNumber cc. WHERE pe.EmployeeNumber = @EmplNbr; dd. END ee. GO ff. CREATE FUNCTION Commercial.GetSales(@EmplNbr nchar(7)) gg. RETURNS TABLE hh. BEGIN ii. SELECT pe.LastName + N', ' + pe.FirstName, jj. cs.SaleDate, cs.Amount kk. FROM Commercial.Sales cs ll. INNER JOIN Personnel.Employees pe mm. ON cs.EmployeeNumber = pe.EmployeeNumber nn. WHERE pe.EmployeeNumber = @EmplNbr; oo. END pp. GO qq. CREATE FUNCTION Commercial.GetSales(@EmplNbr nchar(7)) rr. BEGIN ss. SELECT pe.LastName + N', ' + pe.FirstName AS [Full Name], tt. cs.SaleDate, cs.Amount uu. FROM Commercial.Sales cs vv. INNER JOIN Personnel.Employees pe ww. ON cs.EmployeeNumber = pe.EmployeeNumber

xx. yy. zz.

WHERE pe.EmployeeNumber = @EmplNbr AS TABLE; GO

Evelyne works for a department store. She has created a table of items sold in the store and filled it with some records as follows: CREATE SCHEMA Inventory; GO CREATE TABLE Inventory.StoreItems ( ItemCode int identity(1, 1) not null PRIMARY KEY, DateAcquired date, Name nvarchar(50), Size nvarchar(32), UnitPrice money, DiscountRate decimal ); GO INSERT Inventory.StoreItems(DateAcquired, Name, Size, UnitPrice, DiscountRate) VALUES(N'2011-12-06', N'Mid Lady Bag - Lizard', N'12', 228, NULL), (N'2010-02-22', N'Short-Sleeved Bush Shirt', N'Medium', 59.95, 20), (N'2011-10-12', N'Zip Front Sheath Dress', N'8', 138, NULL), (N'2010-05-24', N'Holly Gladiator Heel Shoes', N'7.5', 198, 40), (N'2011-02-16', N'Short Black Skirt', N'14', 55.85, 0.00), (N'2011-04-18', N'Color-Block Chambray Shirt', N'10', 85.25, 20); GO To make easy to show the records, Evelyne wants to create a stored produce that would produce the item code, the name, the size, and the unit price. How can she write code to create that procedure? . CREATE OBJECT::Inventory.GetItems a. AS PROCEDURE b. SELECT ItemCode, Name, Size, UnitPrice c. FROM Inventory.StoreItems; d. GO e. CREATE PROCEDURE Inventory.GetItems f. AS g. SELECT ItemCode, Name, Size, UnitPrice h. FROM Inventory.StoreItems; i. GO j. CREATE OBJECT::Inventory.GetItems AS PROCEDURE k. BEGIN l. SELECT ItemCode, Name, Size, UnitPrice m. FROM Inventory.StoreItems; n. END o. GO p. CREATE PROCEDURE OBJECT::Inventory.GetItems q. RETURN r. SELECT ItemCode, Name, Size, UnitPrice s. FROM Inventory.StoreItems; t. GO u. CREATE OBJECT::Inventory.GetItems v. RETURN PROCEDURE w. BEGIN

x. SELECT ItemCode, Name, Size, UnitPrice y. FROM Inventory.StoreItems; z. END aa. GO Evelyne works for a department store. She created a stored named GetItems that belongs to a scheman named Inventory. What code can she write to see the results of that stored procedure? . a. b. c. d. e. f. g. h. i. j. SELECT * FROM Inventory.GetItems; GO WITH Inventory.GetItems EXECUTE; GO EXECUTE Inventory.GetItems; GO USE Inventory.GetItems; GO SET Inventory.GetItems ON; GO

Martha is working for an apartment building. She inherited the following table: CREATE SCHEMA Listing; GO CREATE TABLE Listing.Apartment ( UnitNumber nchar(8) not null, Bedrooms int, Bathrooms real, Price money, Deposit money, Available bit ); To protect the table, Martha wants to create a stored procedure named GetUnits that other employees can use to see a list derived from the table. The list will include the unit number, the number of bedrooms, the number of bathrooms, and pricce. Because other people cannot directly execute the new stored procedure, she wants to allow them to use the marthag account. How should she create the stored procedure to make this possible? . CREATE OBJECT::PROCEDURE Registration.GetUnits a. AS b. SET NOCOUNT ON c. SELECT UnitNumber, Bedrooms, Bathrooms, Price d. FROM Listing.Apartments e. WITH EXECUTE AS N'marthag'; f. GO g. CREATE Registration.GetUnits h. AS PROCEDURE i. SET NOCOUNT ON j. SELECT UnitNumber, Bedrooms, Bathrooms, Price k. FROM Listing.Apartments l. WITH EXECUTE AS N'marthag'; m. GO n. CREATE PROCEDURE Registration.GetUnits o. SET USER = N'marthag' p. AS q. SET NOCOUNT ON

r. SELECT UnitNumber, Bedrooms, Bathrooms, Price s. FROM Listing.Apartments; t. GO u. CREATE PROCEDURE Registration.GetUnits v. AS w. SET NOCOUNT ON x. SELECT UnitNumber, Bedrooms, Bathrooms, Price y. FROM Listing.Apartments z. SET USER = N'marthag'; aa. GO bb. CREATE PROCEDURE Registration.GetUnits cc. WITH EXECUTE AS N'marthag' dd. AS ee. SET NOCOUNT ON ff. SELECT UnitNumber, Bedrooms, Bathrooms, Price gg. FROM Listing.Apartments; hh. GO Martha is working for an apartment building. She inherited the following table and its records: CREATE SCHEMA Listing; GO CREATE TABLE Listing.Apartment ( UnitNumber nchar(8) not null, Bedrooms int, Bathrooms real, Price money, Deposit money, Available bit ); INSERT Listing.Apartments VALUES('104', 2, 1.00, 1050.00, 300.00, 0), ('306', 3, 2.00, 1350.00, 425.00, 1), ('105', 1, 1.00, 885.00, 250.00, 1), ('202', 1, 1.00, 950.00, 325.00, 0), ('304', 2, 2.00, 1250.00, 300.00, 0), ('106', 3, 2.00, 1350.00, 425.00, 1), ('308', 0, 1.00, 875.00, 225.00, 1), ('203', 1, 1.00, 885.00, 250.00, 1), ('204', 2, 2.00, 1125.00, 425.00, 1), ('205', 1, 1.00, 1055.00, 350.00, 0); GO Martha wants to create a stored procedure named ShowUnit that takes a unit number as argument and produces the record of the corresponding apartment. How can she write code for that stored procedure? . CREATE OBJECT::Listing.ShowUnit @UnitNbr nchar(8) a. RETURN PROCEDURE b. AS c. SET NOCOUNT ON d. SELECT UnitNumber, Bedrooms, Bathrooms, Price, Deposit, Available e. FROM Listing.Apartments f. WHERE UnitNumber = @UnitNbr; g. GO h. CREATE OBJECT::Listing.ShowUnit @UnitNbr nchar(8)

i. RETURNS PROCEDURE j. AS k. SET NOCOUNT ON l. RETURN SELECT UnitNumber, Bedrooms, Bathrooms, m. Price, Deposit, Available n. FROM Listing.Apartments o. WHERE UnitNumber = @UnitNbr; p. GO q. CREATE PROCEDURE Listing.ShowUnit @UnitNbr nchar(8) r. AS s. SET NOCOUNT ON t. SELECT UnitNumber, Bedrooms, Bathrooms, u. Price, Deposit, Available v. FROM Listing.Apartments w. WHERE UnitNumber = @UnitNbr; x. GO y. CREATE PROCEDURE Listing.ShowUnit z. AS aa. DECLARE @UnitNbr nchar(8) bb. cc. SET NOCOUNT ON dd. RETURN SELECT UnitNumber, Bedrooms, Bathrooms, ee. Price, Deposit, Available ff. FROM Listing.Apartments gg. WHERE UnitNumber = @UnitNbr; hh. GO ii. CREATE PROCEDURE OBJECT::Listing.ShowUnit jj. @UnitNbr nchar(8) kk. BEGIN ll. SET NOCOUNT ON mm. RETURN SELECT UnitNumber, Bedrooms, Bathrooms, nn. Price, Deposit, Available oo. FROM Listing.Apartments pp. WHERE UnitNumber = @UnitNbr; qq. END rr. GO James is working for a department store. He has created two tables and added afew records follows: CREATE TABLE Inventory.Categories ( CategoryID int identity(1, 1) primary key, Category nvarchar(20) not null ); GO CREATE TABLE Inventory.StoreItems ( ItemNumber nvarchar(10) primary key, CategoryID int foreign key references Inventory.Categories(CategoryID), ItemName nvarchar(60) not null, Size nvarchar(20), UnitPrice money ); GO

INSERT INTO Inventory.Categories(Category) VALUES(N'Men'), (N'Women'), (N'Boys'), (N'Girls'),(N'Miscellaneous'); GO INSERT INTO Inventory.StoreItems VALUES(N'264850', 2, N'Long-Sleeve Jersey Dress', N'Petite', 39.95), (N'930405', 4, N'Solid Crewneck Tee', N'Medium', 12.95), (N'924515', 1, N'Hooded Full-Zip Sweatshirt', N'S', 69.95), (N'294936', 2, N'Cool-Dry Soft Cup Bra', N'36D', 15.55); GO The employees of the company are in charge of creating and changing products records. To keep track of the records added or changed from the StoredItems table, James creates a table as follows: CREATE TABLE Inventory.DatabaseOperations ( OperationID int identity(1,1) NOT NULL, ObjectType nchar(20) default N'Table', ObjectName nvarchar(40), PerformedBy nvarchar(50), ActionPerformed nvarchar(max), TimePerformed datetime, CONSTRAINT PK_Operations PRIMARY KEY(OperationID) ); GO When the record of an item has been changed in the StoreItems table, James would like the DatabaseOperations table to receive a notification. How can James create a trigger to perform that operation? . CREATE TRIGGER OBJECT::Inventory.ProductUpdated a. ON Inventory.StoreItems b. FOR UPDATE c. AS d. BEGIN e. INSERT INTO Inventory.DatabaseOperations(ObjectType, f. ObjectName, PerformedBy, g. ActionPerformed, TimePerformed) h. VALUES(DEFAULT, N'StoreItems', SUSER_SNAME(), i. N'Product was updated', GETDATE()) j. END k. GO l. CREATE TRIGGER OBJECT::Inventory.ProductUpdated m. ON Inventory.StoreItems n. FOR UPDATE o. AS p. RETURN q. INSERT INTO Inventory.DatabaseOperations(ObjectType, r. ObjectName, PerformedBy, s. ActionPerformed, TimePerformed) t. VALUES(DEFAULT, N'StoreItems', SUSER_SNAME(), u. N'Product was updated', GETDATE()), v. GO w. CREATE OBJECT::Inventory.ProductUpdated x. ON Inventory.StoreItems y. RETURNS TRIGGER z. WITH UPDATE aa. AS bb. INSERT INTO Inventory.DatabaseOperations(ObjectType, cc. ObjectName, PerformedBy,

dd. ee. ff. gg. hh. ii. jj. kk. ll. mm. nn. oo. pp. qq. rr. ss. tt. uu. vv. ww. xx. yy. zz. aaa. bbb. ccc.

ActionPerformed, TimePerformed) VALUES(DEFAULT, N'StoreItems', SUSER_SNAME(), N'Product was updated', GETDATE()), GO CREATE TRIGGER Inventory.ProductUpdated ON Inventory.StoreItems AFTER UPDATE AS INSERT INTO Inventory.DatabaseOperations(ObjectType, ObjectName, PerformedBy, ActionPerformed, TimePerformed) VALUES(DEFAULT, N'StoreItems', SUSER_SNAME(), N'Product was updated', GETDATE()); GO CREATE OBJECT::Inventory.ProductUpdated ON Inventory.StoreItems AFTER UPDATE AS TRIGGER BEGIN INSERT INTO Inventory.DatabaseOperations(ObjectType, ObjectName, PerformedBy, ActionPerformed, TimePerformed) VALUES(DEFAULT, N'StoreItems', SUSER_SNAME(), N'Product was updated', GETDATE()) END GO

James is working for a department store. He has created two tables and added afew records follows: CREATE TABLE Inventory.Categories ( CategoryID int identity(1, 1) primary key, Category nvarchar(20) not null ); GO CREATE TABLE Inventory.StoreItems ( ItemNumber nvarchar(10) primary key, CategoryID int foreign key references Inventory.Categories(CategoryID), ItemName nvarchar(60) not null, Size nvarchar(20), UnitPrice money ); GO INSERT INTO Inventory.Categories(Category) VALUES(N'Men'), (N'Women'), (N'Boys'), (N'Girls'),(N'Miscellaneous'); GO INSERT INTO Inventory.StoreItems VALUES(N'264850', 2, N'Long-Sleeve Jersey Dress', N'Petite', 39.95), (N'930405', 4, N'Solid Crewneck Tee', N'Medium', 12.95), (N'924515', 1, N'Hooded Full-Zip Sweatshirt', N'S', 69.95), (N'294936', 2, N'Cool-Dry Soft Cup Bra', N'36D', 15.55); GO

The employees regularly create, change, and delete records from the tables. To keep track of operations in the StoredItems table, James creates a table as follows: CREATE TABLE Inventory.DatabaseOperations ( OperationID int identity(1,1) NOT NULL, ObjectType nchar(20) default N'Table', ObjectName nvarchar(40), PerformedBy nvarchar(50), ActionPerformed nvarchar(max), TimePerformed datetime, CONSTRAINT PK_Operations PRIMARY KEY(OperationID) ); GO To know when a record has been deleted from the StoredItems table, James wants a new record to be added to the DatabaseOperations table. How can James create a trigger to get those notifications? . CREATE TRIGGER Inventory.ProductRemoved a. AFTER DELETE b. ON Inventory.StoreItems c. AS d. RETURN e. INSERT INTO Inventory.DatabaseOperations(ObjectType, f. ObjectName, PerformedBy, g. ActionPerformed, TimePerformed) h. VALUES(DEFAULT, N'StoreItems', SUSER_SNAME(), i. N'Existing product deleted', GETDATE()); j. END k. GO l. CREATE TRIGGER Inventory.ProductRemoved m. ON Inventory.StoreItems n. AFTER DELETE o. AS p. INSERT INTO Inventory.DatabaseOperations(ObjectType, q. ObjectName, PerformedBy, r. ActionPerformed, TimePerformed) s. VALUES(DEFAULT, N'StoreItems', SUSER_SNAME(), t. N'Existing product deleted', GETDATE()); u. GO v. CREATE OBJECT::Inventory.ProductRemoved w. RETURNS TRIGGER x. AFTER DELETE y. ON Inventory.StoreItems z. BEGIN aa. RETURN bb. INSERT INTO Inventory.DatabaseOperations(ObjectType, cc. ObjectName, PerformedBy, dd. ActionPerformed, TimePerformed) ee. VALUES(DEFAULT, N'StoreItems', SUSER_SNAME(), ff. N'Existing product deleted', GETDATE()); gg. END hh. GO ii. CREATE OBJECT::Inventory.ProductRemoved jj. AS TRIGGER kk. AFTER DELETE ll. ON Inventory.StoreItems mm. BEGIN

nn. oo. pp. qq. rr. ss. tt. uu. vv. ww. xx. yy. zz. aaa. bbb. ccc. ddd. eee.

INSERT INTO Inventory.DatabaseOperations(ObjectType, ObjectName, PerformedBy, ActionPerformed, TimePerformed) VALUES(DEFAULT, N'StoreItems', SUSER_SNAME(), N'Existing product deleted', GETDATE()); END GO CREATE TRIGGER Inventory.ProductRemoved AFTER DELETE ON Inventory.StoreItems BEGIN INSERT INTO Inventory.DatabaseOperations(ObjectType, ObjectName, PerformedBy, ActionPerformed, TimePerformed) VALUES(DEFAULT, N'StoreItems', SUSER_SNAME(), N'Existing product deleted', GETDATE()); END GO

Richard is a member of a team of programmers who have to create a database for a bank. To keep track of who creates tables in the project, he creates a table as follows: CREATE SCHEMA Management; GO CREATE TABLE Management.Operations ( OperationID int identity(1,1) NOT NULL, ObjectType nchar(20) default N'Table', Employee nvarchar(50), ActionPerformed nvarchar(max), OccurredOn datetime, CONSTRAINT PK_Operations PRIMARY KEY(OperationID) ); GO How can he create a trigger that creates a notification in the above table every time a table is created? . CREATE TRIGGER ObjectAdded a. WHEN CREATE_TABLE b. RETURN TABLE c. AS d. BEGIN e. INSERT INTO Management.Operations(ObjectType, Employee, f. ActionPerformed, OccurredOn) g. VALUES(DEFAULT, SUSER_SNAME(), h. N'Created a new table', GETDATE()); i. END j. GO k. CREATE TRIGGER ObjectAdded l. ON DATABASE m. FOR CREATE_TABLE n. AS o. BEGIN p. INSERT INTO Management.Operations(ObjectType, Employee, q. ActionPerformed, OccurredOn) r. VALUES(DEFAULT, SUSER_SNAME(), s. N'Created a new table', GETDATE()); t. END

u. GO v. CREATE TRIGGER ObjectAdded w. TARGET DATABASE x. WHEN CREATE_TABLE y. AS z. INSERT INTO Management.Operations(ObjectType, Employee, aa. ActionPerformed, OccurredOn) bb. VALUES(DEFAULT, SUSER_SNAME(), cc. N'Created a new table', GETDATE()); dd. END ee. GO ff. CREATE OBJECT::ObjectAdded gg. RETURN TRIGGER hh. WHEN CREATE_TABLE ii. AS TABLE jj. BEGIN kk. SELECT INTO Management.Operations ll. SET ObjectType = N'Table', mm. Employee = SUSER_SNAME(), nn. ActionPerformed = N'Created a new table', oo. OccurredOn = GETDATE(); pp. END qq. GO rr. CREATE OBJECT::ObjectAdded ss. RETURN TRIGGER tt. WHEN CREATE_TABLE uu. AS TABLE vv. BEGIN ww. INSERT INTO Management.Operations(ObjectType, Employee, xx. ActionPerformed, OccurredOn) yy. VALUES(DEFAULT, SUSER_SNAME(), zz. N'Created a new table', GETDATE()); aaa. END bbb. GO Florence is a member of a team of database developers who work for a bank. The database already contains many objects such as tables, views, functions, etc. To find out when somebody creates, changes, or deletes an object, she creates a table as follows: CREATE SCHEMA Management; GO CREATE TABLE Management.Operations ( OperationID int identity(1,1) NOT NULL, ObjectType nchar(20) default N'Table', Employee nvarchar(50), ActionPerformed nvarchar(max), OccurredOn datetime, CONSTRAINT PK_Operations PRIMARY KEY(OperationID) ); GO Now she wants to create a trigger that gets a notification if an employees deletes one of the existing tables of the project. How can she create that trigger? . CREATE TRIGGER TabledRemoved a. WHEN DROP_TABLE b. AS c. INSERT INTO Management.Operations(ObjectType, Employee,

d. ActionPerformed, OccurredOn) e. VALUES(DEFAULT, SUSER_SNAME(), f. N'An existing table was deleted', GETDATE()); g. GO h. CREATE OBJECT::TabledRemoved i. AS TRIGGER j. WHEN DROP_TABLE k. BEGIN l. INSERT INTO Management.Operations(ObjectType, Employee, m. ActionPerformed, OccurredOn) n. VALUES(DEFAULT, SUSER_SNAME(), o. N'An existing table was deleted', GETDATE()); p. END q. GO r. CREATE TRIGGER::TabledRemoved s. ON DATABASE t. WHEN DROP_TABLE u. BEGIN v. INSERT INTO Management.Operations(ObjectType, Employee, w. ActionPerformed, OccurredOn) x. VALUES(DEFAULT, SUSER_SNAME(), y. N'An existing table was deleted', GETDATE()); z. END aa. GO bb. CREATE TabledRemoved cc. RETURNS TRIGGER dd. ON DATABASE ee. WHEN DROP_TABLE ff. BEGIN gg. INSERT INTO Management.Operations(ObjectType, Employee, hh. ActionPerformed, OccurredOn) ii. VALUES(DEFAULT, SUSER_SNAME(), jj. N'An existing table was deleted', GETDATE()); kk. END ll. GO mm. CREATE TRIGGER TabledRemoved nn. ON DATABASE oo. FOR DROP_TABLE pp. AS qq. BEGIN rr. INSERT INTO Management.Operations(ObjectType, Employee, ss. ActionPerformed, OccurredOn) tt. VALUES(DEFAULT, SUSER_SNAME(), uu. N'An existing table was deleted', GETDATE()); vv. END ww. GO What's the name of the stored procedure used to send a notification email when something happens in Microsoft SQL Server? . sp_sendmail

a. sp_dbsend_mail b. sp_send_dbmail c. sp_senddb_mail d. sp_send_mail

Hank has the following tables of employees and sales they made during a certain period: CREATE TABLE Personnel.Employees ( EmployeeNumber nchar(7) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), EmploymentStatus smallint, HourlySalary money ); GO CREATE TABLE Commercial.Sales ( SaleID int identity(1, 1), EmployeeNumber nchar(7) not null, SaleDate date, Amount money ); GO INSERT Personnel.Employees VALUES(N'284-680', N'Anselme', N'Bongos', 2, 18.62), (N'730-704', N'June', N'Malea', 1, 9.95), (N'735-407', N'Frank', N'Monson', 3, 14.58), (N'281-730', N'Jerry', N'Beaulieu', 1, 16.65); GO INSERT INTO Commercial.Sales(EmployeeNumber, SaleDate, Amount) VALUES(N'284-680', N'2011-02-14', 4250), (N'735-407', N'2011-02-14', 5300), (N'730-704', N'2011-02-14', 2880), (N'281-730', N'2011-02-14', 4640), (N'284-680', N'2011-02-15', 4250), (N'281-730', N'2011-02-15', 3675); GO Hank must produce a summary list that shows the employees and the average sale they made during that period. How can he write code to get that result? . SELECT EmployeeNumber, AVG(Amount) a. FROM Sales b. HAVING EmployeeNumber; c. SELECT EmployeeNumber, AVG(Amount) d. FROM Sales e. GROUP BY EmployeeNumber; f. SELECT DISTINCT EmployeeNumber, AVG(Amount) g. FROM Sales; h. GO i. SELECT EmployeeNumber, AVG(Amount) j. FROM Sales k. WHERE EmployeeNumber IS NOT NULL; l. GO m. SELECT EmployeeNumber, AVG(Amount) n. FROM Sales o. GROUP BY Amount; p. GO Hank has the following tables of employees and sales they made during a certain period:

CREATE TABLE Personnel.Employees ( EmployeeNumber nchar(7) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), EmploymentStatus smallint, HourlySalary money ); GO CREATE TABLE Commercial.Sales ( SaleID int identity(1, 1), EmployeeNumber nchar(7) not null, SaleDate date, Amount money ); GO INSERT Personnel.Employees VALUES(N'284-680', N'Anselme', N'Bongos', 2, 18.62), (N'730-704', N'June', N'Malea', 1, 9.95), (N'735-407', N'Frank', N'Monson', 3, 14.58), (N'281-730', N'Jerry', N'Beaulieu', 1, 16.65); GO INSERT INTO Commercial.Sales(EmployeeNumber, SaleDate, Amount) VALUES(N'284-680', N'2011-02-14', 4250), (N'735-407', N'2011-02-14', 5300), (N'730-704', N'2011-02-14', 2880), (N'281-730', N'2011-02-14', 4640), (N'284-680', N'2011-02-15', 4250), (N'281-730', N'2011-02-15', 3675); GO Hank is asked to show a summary list of employees and the average sale they made during that period. The list must contain the employee's full name (made of last name followed by a comma and the first name) and the average sale. How can he write code to get that result? . SELECT e.LastName + N', ' + e.FirstName AS [Full Name], a. AVG(s.Amount) AS [Average Sales] b. FROM Sales s INNER JOIN Employees e c. ON s.EmployeeNumber = e.EmployeeNumber d. GROUP BY e.LastName + N', ' + e.FirstName; e. GO f. SELECT e.LastName + N', ' + e.FirstName AS [Full Name], g. AVG(s.Amount) AS [Average Sales] h. FROM Sales s INNER JOIN Employees e i. ON s.EmployeeNumber = e.EmployeeNumber j. GROUP BY s.EmployeeNumber; k. GO l. SELECT e.EmployeeNumber, AVG(s.Amount) AS [Average Sales] m. FROM Sales s INNER JOIN Employees e n. ON s.EmployeeNumber = e.EmployeeNumber o. GROUP BY e.LastName + N', ' + e.FirstName; p. GO q. SELECT e.LastName + N', ' + e.FirstName AS [Full Name], r. AVG(s.Amount) AS [Average Sales] s. FROM Sales s INNER JOIN Employees e

t. GROUP BY e.EmployeeNumber u. ON s.EmployeeNumber = e.EmployeeNumber; v. GO w. SELECT e.LastName + N', ' + e.FirstName AS [Full Name], x. AVG(s.Amount) AS [Average Sales] y. FROM Sales s INNER JOIN Employees e z. ON s.EmployeeNumber = e.EmployeeNumber aa. HAVING e.EmployeeNumber; bb. GO Martha has the following list of apartments and the records where the first digit of the unit number indicates its floor: CREATE SCHEMA Listing; GO CREATE TABLE Listing.Apartments ( UnitNumber int not null, Bedrooms int, Bathrooms real, Price money, Deposit money, Available bit ); GO INSERT Listing.Apartments VALUES(104, 2, 1.00, 1050.00, 300.00, 0), (306, 3, 2.00, 1350.00, 425.00, 1), (105, 1, 1.00, 885.00, 250.00, 1), (202, 1, 1.00, 950.00, 325.00, 0), (304, 2, 2.00, 1250.00, 300.00, 0), (106, 3, 2.00, 1350.00, 425.00, 1), (308, 0, 1.00, 875.00, 225.00, 1), (203, 1, 1.00, 885.00, 250.00, 1), (204, 2, 2.00, 1125.00, 425.00, 1), (205, 1, 1.00, 1055.00, 350.00, 0); GO What codes can Martha write to get a list of available apartments from the second floor (Select 2)? . SELECT * FROM Listing.Apartments a. WHERE UnitNumber IN(200, 299) AND (Available = 1); b. GO c. SELECT * FROM Listing.Apartments d. WHERE (UnitNumber >= 200) AND (UnitNumber <= 299) AND (Available = 1); e. GO f. SELECT * FROM Listing.Apartments g. WHERE (UnitNumber BETWEEN 200 AND 299) AND (Available = 1); h. GO i. SELECT * FROM Listing.Apartments j. WHERE UnitNumber IN(200, 299) OR (Available = TRUE); k. GO l. SELECT * FROM Listing.Apartments m. WHERE UnitNumber >= 200 AND Available IS NOT NULL; n. GO Jimmy has a database that contains employees records and their time sheets as follows:

CREATE SCHEMA Personnel; GO CREATE SCHEMA Payroll; GO CREATE TABLE Personnel.Employees ( EmployeeNumber nchar(7) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), HourlySalary money ); GO CREATE TABLE Payroll.TimeSheets ( TimeSheetID int identity(1, 1) not null primary key, EmployeeNumber nchar(7) not null foreign key references Personnel.Employees(EmployeeNumber), DateWorked date, TimeWorked decimal(6, 2) ); GO INSERT Personnel.Employees VALUES(N'795-074', N'Steve', N'Leland', 16.46), (N'240-157', N'Alex', N'Randt', 10.55), (N'482-259', N'Janice', N'Lane', 8.64), (N'628-113', N'Jimmy', N'Walters', 20.24); GO INSERT INTO Payroll.TimeSheets(EmployeeNumber, DateWorked, TimeWorked) VALUES(N'240-157', N'2011-04-04', 8.00), (N'628-113', N'2011-04-04', 9.50), (N'795-074', N'2011-04-04', 8.00), (N'482-259', N'2011-04-04', 6.50), (N'795-074', N'2011-04-05', 8.50), (N'482-259', N'2011-04-05', 8.00), (N'240-157', N'2011-04-05', 9.50), (N'628-113', N'2011-04-05', 7.50), (N'795-074', N'2011-04-06', 8.00), (N'240-157', N'2011-04-06', 8.50), (N'795-074', N'2011-04-07', 10.00), (N'628-113', N'2011-04-07', 8.00); GO How can he write code to get a list that contains the employee number, the date he or she worked, and the time spent at work, without repeating records? . SELECT empl.EmployeeNumber [Empl #], a. pts.DateWorked [Date Worked], b. pts.TimeWorked [Time Worked] c. FROM Personnel.Employees empl INNER JOIN Payroll.TimeSheets pts; d. GO e. SELECT empl.FirstName [First Name], empl.LastName [Last Name], f. pts.DateWorked [Date Worked], g. pts.TimeWorked [Time Worked] h. FROM Personnel.Employees empl OUTER JOIN Payroll.TimeSheets pts; i. GO j. SELECT empl.EmployeeNumber [Empl #],

k. l. m. n. o. p. q. r. s. t. u. v. w. x.

FROM GO SELECT pts.EmployeeNumber [Empl #], pts.DateWorked [Date Worked], pts.TimeWorked [Time Worked] FROM Payroll.TimeSheets pts; GO SELECT DISTINCT empl.EmployeeNumber [Empl #], pts.DateWorked [Date Worked], pts.TimeWorked [Time Worked] FROM Personnel.Employees empl, Payroll.TimeSheets pts; GO

pts.DateWorked [Date Worked], pts.TimeWorked [Time Worked] Personnel.Employees empl, Payroll.TimeSheets pts;

Jimmy has a database that contains employees records and their time sheets as follows: CREATE SCHEMA Personnel; GO CREATE SCHEMA Payroll; GO CREATE TABLE Personnel.Employees ( EmployeeNumber nchar(7) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), HourlySalary money ); GO CREATE TABLE Payroll.TimeSheets ( TimeSheetID int identity(1, 1) not null primary key, EmployeeNumber nchar(7) not null foreign key references Personnel.Employees(EmployeeNumber), DateWorked date, TimeWorked decimal(6, 2) ); GO INSERT Personnel.Employees VALUES(N'795-074', N'Steve', N'Leland', 16.46), (N'240-157', N'Alex', N'Randt', 10.55), (N'482-259', N'Janice', N'Lane', 8.64), (N'628-113', N'Jimmy', N'Walters', 20.24); GO INSERT INTO Payroll.TimeSheets(EmployeeNumber, DateWorked, TimeWorked) VALUES(N'240-157', N'2011-04-04', 8.00), (N'628-113', N'2011-04-04', 9.50), (N'795-074', N'2011-04-04', 8.00), (N'482-259', N'2011-04-04', 6.50), (N'795-074', N'2011-04-05', 8.50), (N'482-259', N'2011-04-05', 8.00), (N'240-157', N'2011-04-05', 9.50), (N'628-113', N'2011-04-05', 7.50), (N'795-074', N'2011-04-06', 8.00), (N'240-157', N'2011-04-06', 8.50),

(N'795-074', N'2011-04-07', 10.00), (N'628-113', N'2011-04-07', 8.00); GO He want to get a list that contains the employee number, the first name, the last name, the date worked, and the time worked, without repeating records. What code can he write to get that list? . SELECT empl.EmployeeNumber [Empl #], a. empl.FirstName [First Name], b. empl.LastName [Last Name], c. pts.DateWorked [Date Worked], d. pts.TimeWorked [Time Worked] e. FROM Personnel.Employees empl INNER JOIN Payroll.TimeSheets pts f. ON empl.EmployeeNumber = pts.EmployeeNumber; g. GO h. SELECT empl.EmployeeNumber [Empl #], i. empl.FirstName [First Name], j. empl.LastName [Last Name], k. pts.DateWorked [Date Worked], l. pts.TimeWorked [Time Worked] m. FROM Personnel.Employees empl CROSS JOIN Payroll.TimeSheets pts n. ON empl.EmployeeNumber = pts.EmployeeNumber; o. GO p. SELECT empl.EmployeeNumber [Empl #], q. empl.FirstName + N' ' + empl.LastName [Full Name], r. pts.DateWorked [Date Worked], s. pts.TimeWorked [Time Worked] t. FROM Personnel.Employees empl LEFT INNER JOIN Payroll.TimeSheets pts u. ON empl.EmployeeNumber = pts.EmployeeNumber; v. GO w. x. SELECT DISTINCT(empl.EmployeeNumber, y. empl.FirstName, z. empl.LastName), aa. pts.DateWorked [Date Worked], bb. pts.TimeWorked [Time Worked] cc. FROM Personnel.Employees empl LEFT INNER JOIN Payroll.TimeSheets pts dd. ON empl.EmployeeNumber = pts.EmployeeNumber; ee. GO ff. gg. SELECT empl.EmployeeNumber [Empl #], hh. empl.FirstName [First Name], ii. empl.LastName [Last Name], jj. pts.DateWorked [Date Worked], kk. pts.TimeWorked [Time Worked] ll. FROM Personnel.Employees empl LEFT JOIN Payroll.TimeSheets pts mm. ON empl.EmployeeNumber = pts.EmployeeNumber nn. GROUP BY pts.EmployeeNumber; oo. GO pp. Leslie has a database that contains employees records and their time sheets as follows: CREATE SCHEMA Personnel;

GO CREATE SCHEMA Payroll; GO CREATE TABLE Personnel.Employees ( EmployeeNumber nchar(7) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), HourlySalary money ); GO CREATE TABLE Payroll.TimeSheets ( TimeSheetID int identity(1, 1) not null primary key, EmployeeNumber nchar(7) not null foreign key references Personnel.Employees(EmployeeNumber), DateWorked date, TimeWorked decimal(6, 2) ); GO INSERT Personnel.Employees VALUES(N'795-074', N'Steve', N'Leland', 16.46), (N'240-157', N'Alex', N'Randt', 10.55), (N'482-259', N'Janice', N'Lane', 8.64), (N'628-113', N'Jimmy', N'Walters', 20.24); GO INSERT INTO Payroll.TimeSheets(EmployeeNumber, DateWorked, TimeWorked) VALUES(N'240-157', N'2011-04-04', 8.00), (N'628-113', N'2011-04-04', 9.50), (N'795-074', N'2011-04-04', 8.00), (N'482-259', N'2011-04-04', 6.50), (N'795-074', N'2011-04-05', 8.50), (N'482-259', N'2011-04-05', 8.00), (N'240-157', N'2011-04-05', 9.50), (N'628-113', N'2011-04-05', 7.50), (N'795-074', N'2011-04-06', 8.00), (N'240-157', N'2011-04-06', 8.50), (N'795-074', N'2011-04-07', 10.00), (N'628-113', N'2011-04-07', 8.00); GO What code can Leslie write to get a list that contains each employee number and the total time the employee worked during that time frame? . SELECT pts.EmployeeNumber [Empl #], a. SUM(pts.TimeWorked [Time Worked]) b. FROM Payroll.TimeSheets pts c. GROUP BY pts.EmployeeNumber d. WHERE pts.EmployeeNumber IS NOT NULL; e. GO f. g. SELECT pts.EmployeeNumber [Empl #], h. SUM(pts.TimeWorked [Time Worked]) i. FROM Payroll.TimeSheets pts j. GROUP BY pts.EmployeeNumber k. HAVING pts.EmployeeNumber IS NOT NULL; l. GO

m. n. SELECT pts.EmployeeNumber [Empl #], o. SUM(pts.TimeWorked) [Time Worked] p. FROM Payroll.TimeSheets pts q. GROUP BY pts.EmployeeNumber; r. GO s. SELECT pts.EmployeeNumber [Empl #], t. SUM(pts.TimeWorked) [Time Worked] u. GROUP BY pts.EmployeeNumber v. FROM Payroll.TimeSheets pts; w. GO x. SELECT pts.EmployeeNumber [Empl #], y. SUM(pts.TimeWorked) [Time Worked] z. FROM Payroll.TimeSheets pts aa. GROUP BY pts.TimeWorked; bb. GO Jimmy has a database that contains employees records and their time sheets as follows: CREATE SCHEMA Personnel; GO CREATE SCHEMA Payroll; GO CREATE TABLE Personnel.Employees ( EmployeeNumber nchar(7) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), HourlySalary money ); GO CREATE TABLE Payroll.TimeSheets ( TimeSheetID int identity(1, 1) not null primary key, EmployeeNumber nchar(7) not null foreign key references Personnel.Employees(EmployeeNumber), DateWorked date, TimeWorked decimal(6, 2) ); GO INSERT Personnel.Employees VALUES(N'795-074', N'Steve', N'Leland', 16.46), (N'240-157', N'Alex', N'Randt', 10.55), (N'482-259', N'Janice', N'Lane', 8.64), (N'628-113', N'Jimmy', N'Walters', 20.24); GO INSERT INTO Payroll.TimeSheets(EmployeeNumber, DateWorked, TimeWorked) VALUES(N'240-157', N'2011-04-04', 8.00), (N'628-113', N'2011-04-04', 9.50), (N'795-074', N'2011-04-04', 8.00), (N'482-259', N'2011-04-04', 6.50), (N'795-074', N'2011-04-05', 8.50), (N'482-259', N'2011-04-05', 8.00), (N'240-157', N'2011-04-05', 9.50), (N'628-113', N'2011-04-05', 7.50),

(N'795-074', (N'240-157', (N'795-074', (N'628-113',

N'2011-04-06', N'2011-04-06', N'2011-04-07', N'2011-04-07',

8.00), 8.50), 10.00), 8.00);

GO He want to get a list that contains the employee's name (made of the first name followed by space and the last name) and the time worked, without repeating records. What code can he write to get that list? . SELECT empls.FirstName + N' ' + empls.LastName [Full Name], a. SUM(pts.TimeWorked) [Time Worked] b. FROM Payroll.TimeSheets pts JOIN Personnel.Employees empls c. ON pts.EmployeeNumber = empls.EmployeeNumber d. GROUP BY empls.FirstName + N' ' + empls.LastName; e. GO f. SELECT empls.FirstName + N' ' + empls.LastName [Full Name], g. SUM(pts.TimeWorked) [Time Worked] h. FROM Payroll.TimeSheets pts LEFT OUTER JOIN Personnel.Employees empls i. ON pts.EmployeeNumber = empls.EmployeeNumber j. GROUP BY empls.EmployeeNumber; k. GO l. SELECT empls.FirstName + N' ' + empls.LastName [Full Name], m. SUM(pts.TimeWorked) [Time Worked] n. FROM Payroll.TimeSheets pts LEFT OUTER JOIN Personnel.Employees empls o. ON pts.EmployeeNumber = empls.EmployeeNumber p. GROUP BY pts.TimeWorked; q. GO r. SELECT DISTINCT empls.FirstName + N' ' + empls.LastName [Full Name], s. SUM(pts.TimeWorked) [Time Worked] t. FROM Payroll.TimeSheets pts CROSS JOIN Personnel.Employees empls u. ON pts.EmployeeNumber = empls.EmployeeNumber v. GROUP BY empls.FirstName + N' ' + empls.LastName; w. GO x. SELECT DISTINCT empls.FirstName + N' ' + empls.LastName [Full Name], y. SUM(pts.TimeWorked) [Time Worked] z. ON pts.EmployeeNumber = empls.EmployeeNumber aa. FROM Payroll.TimeSheets pts CROSS JOIN Personnel.Employees empls bb. GROUP BY pts.EmployeeNumber; cc. GO Bill has a database that contains employees records and their time sheets as follows: CREATE SCHEMA Personnel; GO CREATE SCHEMA Payroll; GO CREATE TABLE Personnel.Employees ( EmployeeNumber nchar(7) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), HourlySalary money

); GO CREATE TABLE Payroll.TimeSheets ( TimeSheetID int identity(1, 1) not null primary key, EmployeeNumber nchar(7) not null foreign key references Personnel.Employees(EmployeeNumber), DateWorked date, TimeWorked decimal(6, 2) ); GO INSERT Personnel.Employees VALUES(N'795-074', N'Steve', N'Leland', 16.46), (N'240-157', N'Alex', N'Randt', 10.55), (N'482-259', N'Janice', N'Lane', 8.64), (N'628-113', N'Jimmy', N'Walters', 20.24); GO INSERT INTO Payroll.TimeSheets(EmployeeNumber, DateWorked, TimeWorked) VALUES(N'240-157', N'2011-04-04', 8.00), (N'628-113', N'2011-04-04', 9.50), (N'795-074', N'2011-04-04', 8.00), (N'482-259', N'2011-04-04', 6.50), (N'795-074', N'2011-04-05', 8.50), (N'482-259', N'2011-04-05', 8.00), (N'240-157', N'2011-04-05', 9.50), (N'628-113', N'2011-04-05', 7.50), (N'795-074', N'2011-04-06', 8.00), (N'240-157', N'2011-04-06', 8.50), (N'795-074', N'2011-04-07', 10.00), (N'628-113', N'2011-04-07', 8.00); GO He want to create a list that shows the employee's name (made of the first name followed a space and the last name), the time worked, and the weekly salary that mulitplies the time worked by the employee's hourly salary. What code can he write to get that list? . SELECT empls.FirstName + N' ' + empls.LastName [Full Name], a. SUM(pts.TimeWorked) [Time Worked], b. SUM(pts.TimeWorked * empls.HourlySalary) [Weekly Salary] c. FROM Payroll.TimeSheets pts JOIN Personnel.Employees empls d. ON pts.EmployeeNumber = empls.EmployeeNumber e. GROUP BY empls.FirstName + N' ' + empls.LastName; f. GO g. SELECT empls.FirstName + N' ' + empls.LastName [Full Name], h. SUM(pts.TimeWorked) [Time Worked], i. pts.TimeWorked * empls.HourlySalary AS [Weekly Salary] j. FROM Payroll.TimeSheets pts JOIN Personnel.Employees empls k. ON pts.EmployeeNumber = empls.EmployeeNumber l. GROUP BY empls.FirstName + N' ' + empls.LastName; m. GO n. SELECT empls.FirstName + N' ' + empls.LastName [Full Name], o. SUM(pts.TimeWorked) [Time Worked], p. SUM(pts.TimeWorked) * SUM(empls.HourlySalary) AS [Weekly Salary] q. FROM Payroll.TimeSheets pts JOIN Personnel.Employees empls r. ON pts.EmployeeNumber = empls.EmployeeNumber

s. GROUP BY empls.FirstName + N' ' + empls.LastName; t. GO u. SELECT empls.FirstName + N' ' + empls.LastName [Full Name], v. SUM(pts.TimeWorked) [Time Worked], w. MAX(pts.TimeWorked * empls.HourlySalary) AS [Weekly Salary] x. FROM Payroll.TimeSheets pts JOIN Personnel.Employees empls y. ON pts.EmployeeNumber = empls.EmployeeNumber z. GROUP BY empls.FirstName + N' ' + empls.LastName; aa. GO bb. SELECT empls.FirstName + N' ' + empls.LastName [Full Name], cc. SUM(pts.TimeWorked) [Time Worked], dd. VAL(pts.TimeWorked) * VAL(empls.HourlySalary) AS [Weekly Salary] ee. FROM Payroll.TimeSheets pts JOIN Personnel.Employees empls ff. ON pts.EmployeeNumber = empls.EmployeeNumber gg. GROUP BY empls.FirstName + N' ' + empls.LastName; hh. GO ii. Daouda has a table of employees and another table for their time sheets as follows: CREATE SCHEMA Personnel; GO CREATE SCHEMA Payroll; GO CREATE TABLE Personnel.Employees ( EmployeeNumber nchar(7) not null primary key, FirstName nvarchar(20), LastName nvarchar(20), HourlySalary money ); GO CREATE TABLE Payroll.TimeSheets ( TimeSheetID int identity(1, 1) not null primary key, EmployeeNumber nchar(7) not null foreign key references Personnel.Employees(EmployeeNumber), DateWorked date, TimeWorked decimal(6, 2) ); GO INSERT Personnel.Employees VALUES(N'795-074', N'Steve', N'Leland', 16.46), (N'240-157', N'Alex', N'Randt', 10.55), (N'482-259', N'Janice', N'Lane', 8.64), (N'628-113', N'Jimmy', N'Walters', 20.24); GO INSERT INTO Payroll.TimeSheets(EmployeeNumber, DateWorked, TimeWorked) VALUES(N'240-157', N'2011-04-04', 8.00), (N'628-113', N'2011-04-04', 9.50), (N'795-074', N'2011-04-04', 8.00), (N'482-259', N'2011-04-04', 6.50), (N'795-074', N'2011-04-05', 8.50),

(N'482-259', (N'240-157', (N'628-113', (N'795-074', (N'482-259', (N'240-157', (N'795-074', (N'628-113', (N'240-157', (N'240-157', (N'482-259', (N'628-113', (N'795-074',

N'2011-04-05', N'2011-04-05', N'2011-04-05', N'2011-04-06', N'2011-04-04', N'2011-04-06', N'2011-04-07', N'2011-04-07', N'2011-04-07', N'2011-04-08', N'2011-04-08', N'2011-04-08', N'2011-04-08',

8.00), 9.50), 7.50), 8.50), 6.50), 9.50), 10.00), 8.00), 10.00), 8.50), 6.00), 8.00), 7.50);

GO To evaluate the overtime of employees, Daouda wants to get a list that contains the employee's name (made of the first name followed by space and the last name) and the time worked, only for employees who worked over 40 hours. What code can he write to get that list? . SELECT empls.FirstName + N' ' + empls.LastName [Full Name], a. SUM(pts.TimeWorked) [Time Worked] b. FROM Payroll.TimeSheets pts JOIN Personnel.Employees empls c. ON pts.EmployeeNumber = empls.EmployeeNumber d. GROUP BY empls.FirstName + N' ' + empls.LastName e. WHERE SUM(pts.TimeWorked) >= 40.00; f. GO g. SELECT empls.FirstName + N' ' + empls.LastName [Full Name], h. SUM(pts.TimeWorked) [Time Worked] i. FROM Payroll.TimeSheets pts INNER JOIN Personnel.Employees empls j. WHERE SUM(pts.TimeWorked) >= 40.00; k. ON pts.EmployeeNumber = empls.EmployeeNumber l. GROUP BY empls.FirstName + N' ' + empls.LastName m. GO n. SELECT empls.FirstName + N' ' + empls.LastName [Full Name], o. SUM(pts.TimeWorked) [Time Worked] p. FROM Payroll.TimeSheets pts JOIN Personnel.Employees empls q. ON pts.EmployeeNumber = empls.EmployeeNumber r. GROUP BY empls.FirstName + N' ' + empls.LastName s. HAVING SUM(pts.TimeWorked) >= 40.00; t. GO u. SELECT empls.FirstName + N' ' + empls.LastName [Full Name], v. SUM(pts.TimeWorked) [Time Worked] w. FROM Payroll.TimeSheets pts INNER JOIN Personnel.Employees empls x. HAVING SUM(pts.TimeWorked) >= 40.00; y. ON pts.EmployeeNumber = empls.EmployeeNumber z. GROUP BY empls.FirstName + N' ' + empls.LastName aa. GO bb. SELECT empls.FirstName + N' ' + empls.LastName [Full Name], cc. SUM(pts.TimeWorked) [Time Worked] dd. FROM Payroll.TimeSheets pts INNER JOIN Personnel.Employees empls ee. ON pts.EmployeeNumber = empls.EmployeeNumber ff. HAVING SUM(pts.TimeWorked) >= 40.00 gg. GROUP BY empls.FirstName + N' ' + empls.LastName; hh. GO

Judith is working on a large database for a commercial bank. The database will be named KoloBank. It will have a primary and secondary log files. Judith will store the records of the database in two hard drives: C: and D:. To prepare to eventually load the records, she creates a folder on the C: drive and names it Kolo Bank Primary. She creates another folder in the D: drive and names it Kolo Bank Secondary. To prepare to store the log files, she creates a folder named Kolo Bank Logs on the C: drive. What code can she use to create the database? . CREATE OBJECT DATABASE KoloBank a. ON PRIMARY b. WITH FILEGROUP = KoloBank1 c. ( NAME = N'KoloBankMain', d. FILENAME = N'C:\Kolo Bank Primary\KoloBankMain.mdf', e. SIZE = 100MB, f. MAXSIZE = 500MB, g. FILEGROWTH = 10MB), h. FILEGROUP KoloBankPrimary i. ( NAME = N'KoloBankFirst', j. FILENAME = N'C:\Kolo Bank Primary\KoloBankFirst.ndf', k. SIZE = 20MB, l. MAXSIZE = 100MB, m. FILEGROWTH = 2MB), n. FILEGROUP = KoloBankSecondary o. ( NAME = N'KoloBankSecond', p. FILENAME = N'D:\Kolo Bank Secondary\KoloBankSecondady.ndf', q. SIZE = 20MB, r. MAXSIZE = 100MB, s. FILEGROWTH = 2MB) t. LOG ON FILEGROUP = KoloBankLog u. ( NAME = N'KoloBankLog', v. FILENAME = N'C:\Kolo Bank Logs\KoloBankLogger.ldf', w. SIZE = 10MB, x. MAXSIZE = 20MB, y. FILEGROWTH = 2MB); z. GO aa. CREATE DATABASE KoloBank bb. ON PRIMARY cc. ( NAME = N'KoloBankMain', dd. FILENAME = N'C:\Kolo Bank Primary\KoloBankMain.mdf', ee. SIZE = 100MB, ff. MAXSIZE = 500MB, gg. FILEGROWTH = 10MB), hh. FILEGROUP KoloBankPrimary ii. ( NAME = N'KoloBankFirst', jj. FILENAME = N'C:\Kolo Bank Primary\KoloBankFirst.ndf', kk. SIZE = 20MB, ll. MAXSIZE = 100MB, mm. FILEGROWTH = 2MB), nn. FILEGROUP KoloBankSecondary oo. ( NAME = N'KoloBankSecond', pp. FILENAME = N'D:\Kolo Bank Secondary\KoloBankSecondady.ndf', qq. SIZE = 20MB, rr. MAXSIZE = 100MB, ss. FILEGROWTH = 2MB) tt. LOG ON uu. ( NAME = N'KoloBankLog',

vv. FILENAME = N'C:\Kolo Bank Logs\KoloBankLogger.ldf', ww. SIZE = 10MB, xx. MAXSIZE = 20MB, yy. FILEGROWTH = 2MB); zz. GO aaa. CREATE OBJECT::KoloBank bbb. AS DATABASE ccc. ON PRIMARY ddd. WITH FILEGROUP = KoloBank1 eee. ( NAME = N'KoloBankMain', fff. FILENAME = N'C:\Kolo Bank Primary\KoloBankMain.mdf', ggg. SIZE = 100MB, hhh. MAXSIZE = 500MB, iii. FILEGROWTH = 10MB), jjj. WITH SECONDARY FILEGROUP = KoloBankPrimary kkk. ( NAME = N'KoloBankFirst', lll. FILENAME = N'C:\Kolo Bank Primary\KoloBankFirst.ndf', mmm. SIZE = 20MB, nnn. MAXSIZE = 100MB, ooo. FILEGROWTH = 2MB), ppp. WITH SECONDARY FILEGROUP = KoloBankSecondary qqq. ( NAME = N'KoloBankSecond', rrr. FILENAME = N'D:\Kolo Bank Secondary\KoloBankSecondady.ndf', sss. SIZE = 20MB, ttt. MAXSIZE = 100MB, uuu. FILEGROWTH = 2MB) vvv. WITH LOG FILEGROUP = KoloBankLog www. ( NAME = N'KoloBankLog', xxx. FILENAME = N'C:\Kolo Bank Logs\KoloBankLogger.ldf', yyy. SIZE = 10MB, zzz. MAXSIZE = 20MB, aaaa. FILEGROWTH = 2MB); bbbb. GO cccc. CREATE DATABASE KoloBank dddd. ON PRIMARY eeee. WITH PRIMARY FILEGROUP KoloBank1 ffff. ( NAME = N'KoloBankMain', gggg. FILENAME = N'C:\Kolo Bank Primary\KoloBankMain.mdf', hhhh. SIZE = 100MB, iiii. MAXSIZE = 500MB, jjjj. FILEGROWTH = 10MB), kkkk. WITH SECONDARY FILEGROUP KoloBankPrimary llll. ( NAME = N'KoloBankFirst', mmmm. FILENAME = N'C:\Kolo Bank Primary\KoloBankFirst.ndf', nnnn. SIZE = 20MB, oooo. MAXSIZE = 100MB, pppp. FILEGROWTH = 2MB), qqqq. WITH SECONDARY FILEGROUP ADD KoloBankSecondary rrrr. ( NAME = N'KoloBankSecond', ssss. FILENAME = N'D:\Kolo Bank Secondary\KoloBankSecondady.ndf', tttt. SIZE = 20MB, uuuu. MAXSIZE = 100MB, vvvv. FILEGROWTH = 2MB) wwww. ON LOG FILEGROUP KoloBankLog xxxx. ( NAME = N'KoloBankLog',

yyyy. FILENAME = N'C:\Kolo Bank Logs\KoloBankLogger.ldf', zzzz. SIZE = 10MB, aaaaa. MAXSIZE = 20MB, bbbbb. FILEGROWTH = 2MB); ccccc. GO ddddd. CREATE DATABASE KoloBank eeeee. PRIMARY FILEGROUP = KoloBank1 fffff. ( NAME = N'KoloBankMain', ggggg. FILENAME = N'C:\Kolo Bank Primary\KoloBankMain.mdf', hhhhh. SIZE = 100MB, iiiii. MAXSIZE = 500MB, jjjjj. FILEGROWTH = 10MB), kkkkk. SECONDARY FILEGROUP = KoloBankPrimary lllll. ( NAME = N'KoloBankFirst', mmmmm. FILENAME = N'C:\Kolo Bank Primary\KoloBankFirst.ndf', nnnnn. SIZE = 20MB, ooooo. MAXSIZE = 100MB, ppppp. FILEGROWTH = 2MB), qqqqq. SECONDARY FILEGROUP = KoloBankSecondary rrrrr. ( NAME = N'KoloBankSecond', sssss. FILENAME = N'D:\Kolo Bank Secondary\KoloBankSecondady.ndf', ttttt. SIZE = 20MB, uuuuu. MAXSIZE = 100MB, vvvvv. FILEGROWTH = 2MB) wwwww. ON LOG FILEGROUP = KoloBankLog xxxxx. ( NAME = N'KoloBankLog', yyyyy. FILENAME = N'C:\Kolo Bank Logs\KoloBankLogger.ldf', zzzzz. SIZE = 10MB, aaaaaa. MAXSIZE = 20MB, bbbbbb. FILEGROWTH = 2MB); cccccc. GO Brian is working on a large database for a commercial bank. His colleague Judith has already created the database as follows: CREATE DATABASE KoloBank ON PRIMARY ( NAME = N'KoloBankMain', FILENAME = N'C:\Kolo Bank Primary\KoloBankMain.mdf', SIZE = 100MB, MAXSIZE = 500MB, FILEGROWTH = 10MB), FILEGROUP KoloBankPrimary ( NAME = N'KoloBankFirst', FILENAME = N'C:\Kolo Bank Primary\KoloBankFirst.ndf', SIZE = 20MB, MAXSIZE = 100MB, FILEGROWTH = 2MB), FILEGROUP KoloBankSecondary ( NAME = N'KoloBankSecond', FILENAME = N'D:\Kolo Bank Secondary\KoloBankSecondady.ndf', SIZE = 20MB, MAXSIZE = 100MB, FILEGROWTH = 2MB) LOG ON ( NAME = N'KoloBankLog',

FILENAME = N'C:\Kolo Bank Logs\KoloBankLogger.ldf', SIZE = 10MB, MAXSIZE = 20MB, FILEGROWTH = 2MB); GO Because of the large volume of records that the project will have, the database must be partitioned. To start, Brian has been asked to create a function that will partition records from left to right. The column used to manage the partitions will be of type int. What code can Brian use to create the partitions? . USE KoloBank; a. GO b. CREATE PARTITION FUNCTION KoloBankPartitions(int) c. WITH VALUES(1) d. IN RANGE LEFT; e. GO f. USE KoloBank; g. GO h. CREATE FUNCTION KoloBankPartitions(int) i. RETURNS PARTITION j. FOR VALUES(1) k. AS RANGE LEFT; l. GO m. USE KoloBank; n. GO o. CREATE OBJECT::FUNCTION KoloBankPartitions(int) p. AS PARTITION q. FOR VALUES(1) r. AS RANGE LEFT; s. GO t. USE KoloBank; u. GO v. CREATE PARTITION FUNCTION KoloBankPartitions(int) w. AS RANGE LEFT x. FOR VALUES(1); y. GO z. USE KoloBank; aa. GO bb. CREATE PARTITION FUNCTION KoloBankPartitions(int) cc. FOR VALUES(1) dd. AS RANGE LEFT; ee. GO Brian is working on a large database for a commercial bank. His colleague Judith has already created the database as follows: CREATE DATABASE KoloBank ON PRIMARY ( NAME = N'KoloBankMain', FILENAME = N'C:\Kolo Bank Primary\KoloBankMain.mdf', SIZE = 100MB, MAXSIZE = 500MB, FILEGROWTH = 10MB), FILEGROUP KoloBankPrimary ( NAME = N'KoloBankFirst', FILENAME = N'C:\Kolo Bank Primary\KoloBankFirst.ndf', SIZE = 20MB, MAXSIZE = 100MB,

FILEGROWTH = 2MB), FILEGROUP KoloBankSecondary ( NAME = N'KoloBankSecond', FILENAME = N'D:\Kolo Bank Secondary\KoloBankSecondady.ndf', SIZE = 20MB, MAXSIZE = 100MB, FILEGROWTH = 2MB) LOG ON ( NAME = N'KoloBankLog', FILENAME = N'C:\Kolo Bank Logs\KoloBankLogger.ldf', SIZE = 10MB, MAXSIZE = 20MB, FILEGROWTH = 2MB); GO Based on the large volume of records that the project will have, the database must be partitioned. A partition function was already created as follows: USE KoloBank; GO CREATE PARTITION FUNCTION KoloBankPartitions(int) AS RANGE LEFT FOR VALUES(1); GO To tie the file groups to the scheme, Brian must create a partition function. How can he write code to create the appropriate partition scheme? . USE KoloBank; a. GO b. CREATE PARTITION SCHEME KoloBankScheme c. AS PARTITION KoloBankPartitions d. TO (KoloBankPrimary, KoloBankSecondary); e. GO f. CREATE FUNCTION KoloBankScheme g. AS PARTITION SCHEME h. WITH PARTITION KoloBankPartitions i. FOR (KoloBankPrimary, KoloBankSecondary); j. GO k. CREATE OBJECT::KoloBankScheme l. RETURNS PARTITION SCHEME m. FOR PARTITION KoloBankPartitions n. ON (KoloBankPrimary, KoloBankSecondary); o. GO p. CREATE PARTITION SCHEME KoloBankScheme q. FOR PARTITION KoloBankPartitions r. ON (KoloBankPrimary, KoloBankSecondary); s. GO t. CREATE OBJECT::KoloBankScheme u. AS PARTITION SCHEME v. ON PARTITION KoloBankPartitions w. TO (KoloBankPrimary, KoloBankSecondary); x. GO Julia is working on a large database for a commercial bank. A colleague has already created the database as follows: CREATE DATABASE KoloBank ON PRIMARY ( NAME = N'KoloBankMain', FILENAME = N'C:\Kolo Bank Primary\KoloBankMain.mdf',

SIZE = 100MB, MAXSIZE = 500MB, FILEGROWTH = 10MB), FILEGROUP KoloBankPrimary ( NAME = N'KoloBankFirst', FILENAME = N'C:\Kolo Bank Primary\KoloBankFirst.ndf', SIZE = 20MB, MAXSIZE = 100MB, FILEGROWTH = 2MB), FILEGROUP KoloBankSecondary ( NAME = N'KoloBankSecond', FILENAME = N'D:\Kolo Bank Secondary\KoloBankSecondady.ndf', SIZE = 20MB, MAXSIZE = 100MB, FILEGROWTH = 2MB) LOG ON ( NAME = N'KoloBankLog', FILENAME = N'C:\Kolo Bank Logs\KoloBankLogger.ldf', SIZE = 10MB, MAXSIZE = 20MB, FILEGROWTH = 2MB); GO Another colleague created a partition function and a partition scheme: USE KoloBank; GO CREATE PARTITION FUNCTION KoloBankPartitions(int) AS RANGE LEFT FOR VALUES(1); GO CREATE PARTITION SCHEME KoloBankScheme AS PARTITION KoloBankPartitions TO (KoloBankPrimary, KoloBankSecondary); GO As the main database developer, Julia has to create a table that will store customers records. Among others, the table will have a column named CustomerID of type int. The above partition scheme will decide what file group must hold the records. How should the table be created? . WITH KoloBankScheme a. CREATE TABLE Customers b. ( c. CustomerID int identity(1, 1) primary key, d. AccountNumber nchar(10) not null, e. FirstName nvarchar(20), f. LastName nvarchar(20) not null g. ) h. USE CustomerID AS PARTITION; i. GO j. CREATE TABLE Customers k. ( l. CustomerID int identity(1, 1) primary key m. WITH KoloBankScheme, n. AccountNumber nchar(10) not null, o. FirstName nvarchar(20), p. LastName nvarchar(20) not null q. );

r. GO s. CREATE TABLE Customers t. ( u. CustomerID int identity(1, 1) primary key, v. AccountNumber nchar(10) not null, w. FirstName nvarchar(20), x. LastName nvarchar(20) not null y. ) ON KoloBankScheme(CustomerID); z. GO aa. CREATE TABLE Customers1 bb. ( cc. CustomerID int identity(1, 1) primary key, dd. AccountNumber nchar(10) not null, ee. FirstName nvarchar(20), ff. LastName nvarchar(20) not null gg. ); hh. SET PARTITION::KoloBankScheme FOR CustomerID; ii. GO jj. USING KoloBankScheme(CustomerID) kk. CREATE TABLE Customers ll. ( mm. CustomerID int identity(1, 1) primary key, nn. AccountNumber nchar(10) not null, oo. FirstName nvarchar(20), pp. LastName nvarchar(20) not null qq. ); rr. GO Marc is creating a table to hold the employees of his organization. He has started the table as follows: CREATE TABLE Employees ( EmployeeNumber nchar(60), FirstName nvarchar(20), LastName nvarchar(20), HourlySalary money, FullName AS LastName + N', ' + FirstName, ); GO He wants the value of the FullName column to be saved in memory as an actual value. If it is possible, how should Marc modify code to make it happen? . a. b. c. d. e. f. g. h. i. j. k. l. m. The value of computed column cannot be saved CREATE TABLE Employees ( EmployeeNumber nchar(60), FirstName nvarchar(20), LastName nvarchar(20), HourlySalary money, FullName AS LastName + N', ' + FirstName PERSISTED, ); GO CREATE TABLE Employees ( EmployeeNumber nchar(60), FirstName nvarchar(20),

n. o. p. q. r. s. t. u. v. w. x. y.

LastName nvarchar(20), HourlySalary money, PERSIST FullName AS LastName + N', ' + FirstName,

); GO CREATE TABLE Employees ( EmployeeNumber nchar(60), FirstName nvarchar(20), LastName nvarchar(20), HourlySalary money, FullName AS LastName + N', ' + FirstName CONSTRAINT PERSITENT, z. ); aa. GO bb. CREATE TABLE Employees cc. ( dd. EmployeeNumber nchar(60), ee. FirstName nvarchar(20), ff. LastName nvarchar(20), gg. HourlySalary money, hh. FullName AS LastName + N', ' + FirstName, ii. CONSTRAINT P_FullName PERSISTANCE(FullName) jj. ); kk. GO

Answers
1. Answers a. Right Answer: That's the right answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 2. Answers a. Wrong Answer b. Wrong Answer c. Right Answer: That's the right answer d. Wrong Answer e. Wrong Answer 3. Answers a. Wrong Answer: There is no sp_autogenerate stored procedure b. Wrong Answer: Adding the ProductID in the INSERT statement will only continue with the error c. Wrong Answer: Calling the MAX() aggregate function may produce the highest product number but would not lead to a solution

d. Right Answer: Setting IDENTITY_INSERT to OFF will make it possible to recover from a previous IDENTITY_INSERT set to ON. The code to do this is: e. SET IDENTITY_INSERT Products OFF; GO f. Wrong Answer: There is no AUTOINCREMENT keyword in Transact-SQL

4. Answers a. Wrong Answer: The SET operator is not used to create an index b. Wrong Answer: The AS keyword will cause an error c. Right Answer: That's a good way to create an index d. Wrong Answer: There is no selection to make when creating an index e. Right Answer: The CREATE INDEX expression is not followed by EXEC 5. Answers a. Wrong Answer: CREATE PRIMARY KEY WITH is not a valid expression b. Wrong Answer: That's one way to create a primary key c. Right Answer: That's another way to create a primary key d. Wrong Answer: The REFERENCES keyword is not used to create a primary key e. Right Answer: That's one more way to create a primary key 6. Answers a. Wrong Answer: The code will produce an error because the COUNT() function doesn't define what employee number it is referring to b. Right Answer: That code will produce the list of employee with the number of sales each made c. Wrong Answer: The position of the GROUP BY clause will cause an error d. Wrong Answer: The "HAVING Amount NOT NULL" expression has no meaning e. Wronog Answer: The WHERE clause will cause an error 7. Answers a. Wrong Answer: That is the wrong position to include the check option clause b. Wrong Answer: That is the wrong position to include the check option clause c. Wrong Answer: There is no SET CHECK OPTION ON expression d. Right Answer: That code will make sure any new record added through the view obeys the condition e. Wronog Answer: That's a wrong to create a check option 8. Answers a. Wrong Answer: Yes there is something wrong with that code. It will produce an error b. Wrong Answer: There is no such a limit on the nchar data type c. Right Answer: You can use either UNIQUE or PRIMARY KEY, but not both d. Wrong Answer: Yes it can, as long as you follow some rules

e. Wronog Answer: That's a nice suggestion but it is not a rule 9. Answers a. Wrong Answer: The UPDATE keyword is not used to modify a view b. Right Answer: That code will change the view c. Wrong Answer: There is no stored procedure named sp_change d. Wrong Answer: If you want to change a view, you must indicate the complete list of columns e. Wrong Answer: The ADD keyword does not add a new column to a view 10. Answers a. Wrong Answer: ALL and the asterisk will caus an error b. Wrong Answer: That code will remove members who are not suspended c. Wrong Answer: There is no REMOVE keyword in Transact-SQL d. Wrong Answer: There no stored procedure named sp_remove e. Right Answer: That code will delete all suspended members 11. Answers a. Wrong Answer: That code will update the records of human resources employees to change them to the personnel department b. Right Answer: That code will update the records of employees from the personnel department, change them to the human resources department, and show the list of records that were changed c. Wrong Answer: The DELETED word will produce an error d. Wrong Answer: The OUTPUT clause must come after the UDATE expression e. Wrong Answer: The expressions are misplaced in that formula 12. Answers a. Wrong Answer: The ItemDescription doesn't have a default value. Therefore, omitting it would cause an error b. Right Answer: c. Wrong Answer: The number of fields in the INSERT code is lower than the actual number of fields in the table d. Right Answer: 13. Answers a. Wrong Answer: There is no difference writing the INSERT INTO code before or after the CREATE USER code b. Wrong Answer: The primary key doesn't control whether records can be updated or not on a table c. Right Answer: In order to be able to update records, a user must be granted at least both SELECT and UPDATE permissions d. Wrong Answer: That whole answer doesn't make sense

e. Wrong Answer: In Transact-SQL, you specify whatever name you want to use when creating a user. It can even be a fictitious name 14. Answers a. Wrong Answer: The option to grant permissions is missing b. Wrong Answer: There is no CONNECT permission on tables c. Right Answer: d. Wrong Answer: GRANT OPTION = ALL is not a valid Transact-SQL statement e. Wrong Answer: WITH OPTION GRANT ALL is not a valid Transact-SQL statement 15. Answers a. Wrong Answer: The statement is fine and Teachers.CourseID is valid b. Wrong Answer: The result will include CourseID since it is in the SELECT statement c. Right Answer: In order to be able to update records, a user must be granted at least both SELECT and UPDATE permissions d. That answer doesn't make sense: A SELECT statement doesn't specify what a primary key is e. Wrong Answer: The result will show all three fields 16. Answers a. Wrong Answer: [CMST 320] is not valid b. Right Answer: This will show all records of the Teachers table c. Wrong Answer: The WHEN keyword is not valid in this context d. Right Answer: This will show all records that match the name of the teacher e. Right Answer: This will show all teachers whose CourseID match the criterion 17. Discussions a. Wrong Answer: Either CourseID or Teachers.CourseID is valid b. Wrong Answer: The teachers will not appear in the result c. Wrong Answer: The teachers will not appear in the result d. Right Answer: e. Wrong Answer: The other columns must not be included in the statement 18. Discusions a. Wrong Answer: Only one of those fields can be used. If both are used with the GROUP BY clause, the statement produces an error b. Wrong Answer: The statement produces an error because there is no aggregate function to validate the GROUP BY clause c. Right Answer: This produces the list of courses and the number of teachers who teach that course d. Right Answer: This produces the list of teachers and the number of courses that each teacher teaches

e. Wrong Answer: The field i the SELECT section must be the same in the GROUP BY clause f. Wrong Answer: The field i the SELECT section must be the same in the GROUP BY clause

19. Discussions a. Right Answer: b. Wrong Answer: c. Wrong Answer: d. Wrong Answer: e. Wrong Answer: 20. Answers a. Wrong Answer: If/Since the user is able to see the table (she didn't say that she could not connect to the database; she said she was denied the ability to create records), then she is able to connect to the database. The CONNECT permission is not an issue b. Wrong Answer: If you were able to execute the script, it means there is no problem with the username. Besides, that username is fine c. Right Answer: Since the script included the permissions, you must make sure you grant the right ones. Even though you granted the INSERT permission, it is not enough. The following script should solve the problem: d. e. f. g. h. i. j. USE SuperMarket1; GO GRANT SELECT ON OBJECT::Personnel.Employees TO [Hermine]; GO Wrong Answer: That is not an issue. We assume that you are the database administrator/developer and system administrator Wrong Answer: Who marked the table as read-only and why? That was not an issue

21. Answers a. Right Answer: A view must not include ORDER BY, unless the SELECT statement has a TOP clause b. Wrong Answer: The empl name is an alias for the table and it doesn't have to be in square brackets. Since the names of fields probably include spaces, they can also include space in this context c. Wrong Answer: The names of columns can contain space is they contain space in the original table d. Wrong Answer: If the ORDER BY were possible, it would be written after the FROM expression e. Wrong Answer: The name of a view can/must be preceded by a schema 22. Answers

a. Right Answer: You cannot create a view from a temporary table b. Wrong Answer: Since you cannot create a temporary view, the name of a view cannot start with # c. Wrong Answer: Both SQL and Transact-SQL allow names of objects to contain space d. Wrong Answer: The name of a temporary table must start with # e. Wrong Answer: That answer doesn't make sense. A primary key has nothing to do with the type of table: temporary or not 23. Answers a. Wrong Answer: The result will show the list of teachers and the courses they teach. That code is the same as: b. SELECT TeacherID, FullName, Teachers.CourseID c. FROM Teachers d. Wrong Answer: That code will produce an error because of the position of OUTER e. Wrong Answer: The result will show the list of teachers and the courses they teach f. Wrong Answer: That code will show a list of courses: their codes and names

g. Right Answer: This will produce the list of all Teachers whether they have a matching CourseID record in the Courses table or not 24. Answers a. Right Answer: The result is the list of all employees and the department each employee belongs to b. Wrong Answer: This would have been possible with a CROSS join, but that's not the type of join in the code c. Wrong Answer: The database engine is able to recognize the relationship based on the types of fields d. Wrong Answer: The code will not produce any error e. Wrong Answer: That answer doesn't make sense. That answer is too vague 25. Answers a. Wrong Answer: There is no error in either code b. Right Answer: Both codes produce the same error c. Wrong Answer: There is no error in either code d. Wrong Answer: There is no error in either code e. Wrong Answer: Both codes are the same 26. Answers a. Wrong Answer: There is no error in the code. The WHERE expression is always written after the FROM clause b. Wrong Answer: Including or omitting the Departments.DepartmentCode field depends on the intended result but has no effect on the final result

c. Right Answer: The result will consist of a list of employees who belong to the Research & Development department d. Wrong Answer: That answer doesn't makle sense e. Wrong Answer: The list will not include employees not in the RSDV department 27. Answers a. Wrong Answer: Yes you can delete a view b. Wrong advice: It appears that Maggie wants to delete a view, nothing to do with a table c. Wrong advice: There is no reason to worry about the schema d. Wrong Answer: There is no reason to worry about the records. The records are stored in the table(s), not the view e. Right Answer: When you decide the delete a view, the main concern is about the permissions because they would be lost. If you decide to re-create the view, you must grant the same permissions to the users who had access to the old view 28. Answers a. Wrong Answer: Yes triggers use or need a schema b. Wrong Answer: We need neither a user nor a login. It appears that Frank just wants to tes code and chose not to specify a user or login. Besides, since the original code executes successfully, the user name or login are not an issue c. Wrong Answer: That will not solve the problem d. Right Answer: Both the Customers table and the ForCustomers triger must use the same schema e. Wrong Answer: The presence or absence of a primary key will not determine whether Frank can create a record or not. In fact, the error has nothing to do with any of the tables in the database. The error is related to the trigger 29. Answers a. Wrong Answer: That's not how the IN operator is used b. Right Anwer: That code will produce the list of apartments from the second floor c. Wrong Answer: There is no FROM ... TO condition in SQL d. Right Anwer: That code will produce the list of apartments from the second floor e. Wrong Answer: The FROM 200 TO 300 expression is invalid 30. Answers a. Right Answer: That will work b. Wrong Answer: That code will produce an erro because of the presence of CONSTRAINT c. Right Answer: That's another valid way to create a check constraint

d. Wrong Answer: That code will produce an error because of ON e. Wrong Answer: That code uses an invalid formula to create a check constraint 31. Answers a. Wrong Answer: 20.15 is not the highest salary in the Research & Development department b. Wrong Answer: The value seems to come from a department different than the one in the WHERE condition c. Right Answer: The code produces the highest paid salary in the Research & Development department d. Wrong Answer: That value is from the Accounting department e. Wrong Answer: That's not the highest salary in the Research & Development department 32. Answers a. Right Answer: That's the right sequence of keywords to produce a number of records b. Wrong Answer: The AS clause must be included after a column c. Wrong Answer: The FROM keyword must not follow SELECT d. Wrong Answer: When a WHERE condition is used, it must be included after the FROM statement e. Wrong Answer: The WHERE condition is not added immediately after SELECT 33. Answers a. Wrong Answer: FROM cannot follow SELECT b. Wrong Answer: FROM cannot follow SELECT c. Right Answer: The MAX() function is used to get the highest value of a column d. Wrong Answer: There is no HIGH function in Transact-SQL e. Wrong Answer: If used, the AS clause must be included (immediately) after the column 34. Answers a. Wrong Answer: That code will produce the highest salary in the research & developement department b. Right Answer: That code will produce the highest salary in the human resources department c. Wrong Answer: The presence of OUTER will produce an error in that code d. Wrong Answer: There is no aggregate function named HIGH in Transact-SQL e. Wrong Answer: There is no function or stored procedure named sp_high 35. Answers

a. Right Answer: That code will produce the list of employees and their manager name, if any, in the last column. If an employee does not have a manager, the last column shows NULL b. Wrong Answer: A subquery can include only one column c. Wrong Answer: A subquery must produce only one value d. Wrong Answer: That code will produce the list of employees but the last column shows the salaries e. Wrong Answer: That code will produce the list of employees but the last column shows the name of the employee from the first column 36. Answers a. Right Answer: That code will produce the list of employees who have a manager and will show the name of that manager on the last column b. Wrong Answer: That code will produce the list of employees and their manager's name, but the list includes the employees who don't have a manager c. Wrong Answer: You don't use an IS or IS NO condition after an AS alias d. Wrong Answer: That code will produce the list of employees and their manager's employee number. The list also includes the employees who don't have a manager e. Wrong Answer: The NOT NULL expression is misplaced 37. Answers a. Wrong Answer: A sub-query must include only one column b. Right Answer: That code will produce the list of employees, their salaries, and their manager's name c. Wrong Answer: The parts of a WHERE statement must be on the same type. Those in empl.EmployeeNumber = sal.SalaryID are not d. Wrong Answer: There no SalaryID in the Employees table e. Wrong Answer: Although that code will work fine, it shows the employee number twice, in the last two columns 38. Answers a. Wrong Answer: A subquery must include a condition b. Wrong Answer: The value provided by the subquery is a different type than the one expected by the WHERE condition c. Right Answer: That code will produce the necessary information d. Wrong Answer: That will simply give a list of all employees and show a common salary for all of them e. Wrong Answer: That code produces all employees 39. Answers a. Wrong Answer: That code will move the employees from the human resources department to the personnel department

b. Right Answer: That code will move the employees from the personnel department to the human resources department c. Wrong Answer: The FROM keyword will produce an error d. Wrong Answer: The SET and the UDATE keywords are inversed e. Wrong Answer: The SET and the UDATE keywords are inversed 40. Answers a. Wrong Answer: That code will delete the table, including all of its records b. Wrong Answer: There is no REMOVE operator in Transact-SQL c. Wrong Answer: The asterisk is not used in a DELETE operation d. Right Answer: That code will delete all records from the table but keep the table itself e. Wrong Answer: There is no stored procedure with that name 41. Answers a. Wrong Answer: BEGIN and END are not used when creating a view b. Right Answer: That code creates a view that includes the employee number, the first name, and the last name c. Wrong Answer: The RETURN TABLE expression has no meaning here d. Wrong Answer: WITH and END have no meaning here e. Wrong Answer: The EXECUTE keyword is not used to create a view 42. Answers a. Wrong Answer: The UPDATE keyword is not used to modify a table b. Right Answer: That code will change the table and add the new column c. Wrong Answer: There is no EXECUTE MODIFY expresion in Transact-SQL d. Wrong Answer: There is stored procedure named sp_change e. Wrong Answer: The AS keyword must not be used 43. Answers a. Wrong Answer: The WITH keyword will create an error b. Right Answer: That code adds a new column that will act as a primary key c. Right Answer: That code adds a new column that will act as a primary key d. Wrong Answer: The UPDATE keyword is not used to change a table e. Wrong Answer: That formula will produce an error 44. Answers a. Right Answer: That code will produce the list of employees whose last names end with a b. Wrong Answer: The underscore would not produce the needed result c. Wrong Answer: Including a in square brackets would not accomplish anything d. Wrong Answer: Preceding a with an accent would not do anything

e. Wrong Answer: The exclamation point is not a valid wildcard in Transact-SQL 45. Answers a. Wrong Answer: Considering that 0 is a value, if a product has receive 0 as its discount, then it actually has a discount b. Wrong Answer: That code will not produce anything c. Wrong Answer: That code will show the list of products whose discount is not 0 d. Wrong Answer: That code will produce an error because there is no operator before NULL e. Right Answer: That code will show a list of products that have a discount 46. Answers a. Wrong Answer: There is no such an expression as SET ENCRYPTION ON b. Wrong Answer: There is no ENCRYPT WHEN DONE valid expression c. Right Answer: To encrypt the entry code of a view in a database, use WITH ENCRYPTION after the name of the view d. Wrong Answer: The place to specify encryptio is wrong e. Wrong Answer: There is no such a thing as SET ENCRYPTION ON 47. Answers a. Wrong Answer: There is no reson to select anything when granting a permission b. Right Answer: That code will grant the ALTER permission to Peter c. Wrong Answer: There is no stored procedure named sp_grant d. Wrong Answer: There is PERMISSION keyword to be used when granting a permission e. Wrong Answer: There is no such a thing as SET PERMISSION GRANT 48. Answers a. Wrong Answer: There is no value DO SCHEMA BINDING expression in Transact-SQL b. Wrong Answer: The SCHEMA BINDING expression will create an error c. Wrong Answer: The FOR word will cause an error d. Right Answer: To bind a schema to its parent table, add a WITH SCHEMABINDING clause when creating the view e. Wrong Answer: There is no valid SET SCHEMA BINDING expression 49. Answers a. Wrong Answer: The order of HAVING and GROUP BY is not right b. Wrong Answer: The presence of SUM will make this code show all employees c. Right Answer: That code will show the employees who made sales over 4750 d. Wrong Answer: The WHERE clause will cause that code to produce an error

e. Wrong Answer: The WHERE condition creates an error 50. Answers a. Right Answer: That code will show the list of employees. Each record will show the first name, the last name and the number of sales the employee made. The number of sales are ordered in ascending order b. Wrong Answer: Since the Amount is not represented in the SELECT statement, the code will produce an error c. Wrong Answer: The presences of ORDER BY, HAVING, and ORDER BY as misplaced d. Wrong Answer: The FROM expression must come immediately after the SELECT statement e. Wrong Answer: The GROUP BY expression must be the last 51. Answers a. Wrong Answer: There is no valid RENAME COLUMN expression in TransactSQL b. Wrong Answer: There is no RENAME operator to rename a column c. Right Answer: You use the sp_rename stored procedure to rename a columne and you should add N'COLUMN' d. Wrong Answer: There in stored procedure named sp_changename e. Wrong Answer: There is no RENAME operator to rename a column 52. Answers a. Wrong Answer: The DELETE keyword is not used to remove a column b. Wrong Answer: The SET keyword is not used to remove a column c. Wrong Answer: The UPDATE keyword is not used to remove a column d. Right Answer: That code will delete the column e. Wrong Answer: The UPDATE keyword is not used to remove a column and the SET keyword cannot be used as in this code 53. Answers a. Right Answer: That code will show the records from the Employees table. Each record will show each of the records from the second table. The result will include only products that cost more than 50.00 b. Wrong Answer: There is no reason to use DISTINCT here c. Wrong Answer: You cannot create a Boolean operation between a stringbased column ([Empl #] and a number-based column (Number) d. Wrong Answer: You can't use GROUP BY since there is no aggregate function in the statement e. Wrong Answer: Since the unit price is not used in an aggregate function in the SELECT statement, this code will produce an error 54. Answers

a. Wrong Answer: Unlike the primary key that can be created separate from its column, a foreign key must be created in the statement of its column b. Right Answer: That code will create a foreign key that references a column from the Employees table c. Right Answer: That's another way to create a primary key d. Wrong Answer: If you decide to use the CONSTRAINT keyword, you must create a name for the foreign key e. Wrong Answer: CREATE FOREIGN KEY WITH is not a valid expression 55. Answers a. Wrong Answer: You don't specify the name of the column when deleting an index b. Wrong Answer: The DELETE keyword is not valid in this context c. Wrong Answer: The FROM keyword will cause an error d. Right Answer: That's the code to delete an index e. Wrong Answer: The DELETE keyword cannot be used like that 56. Answers a. Wrong Answer: The combination of word after ALTER TABLE is not valid b. Wrong Answer: You don't use UPDATE to add a new column c. Wrong Answer:The AS keyword is not used when adding a new column d. Wrong Answer: There is no CHANGE keyword to be used here e. Right Answer: That code will add a new column that is a foreign key 57. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Right Answer: That's the right formula 58. Answers a. Wrong Answer b. Wrong Answer c. Right Answer: That's the right formula d. Wrong Answer e. Wrong Answer 59. Answers a. Right Answer: That's the right answer b. Wrong Answer c. Wrong Answer

d. Wrong Answer e. Wrong Answer 60. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer d. Right Answer: That's the right answer e. Wrong Answer 61. Answers a. Wrong Answer b. Right Answer: That's the right answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 62. Answers a. Wrong Answer b. Wrong Answer c. Right Answer: That's the right answer d. Wrong Answer e. Wrong Answer 63. Answers a. Wrong Answer: There is no AUTONUMBER in Transact-SQL b. Wrong Answer: The COUNTER word will produce an error c. Wrong Answer: There is no AUTOINCREMENT in Transact-SQL d. Right Answer: That's the right answer e. Wrong Answer 64. Answers a. Right Answer: That's the right answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 65. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer

d. Right Answer: That's the right answer e. Wrong Answer 66. Answers a. Wrong Answer b. Right Answer: That's the right answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 67. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Right Answer: That's the right answer 68. Answers a. Right Answer: That's the right answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 69. Answers a. Wrong Answer b. Wrong Answer c. Right Answer: That's the right answer d. Wrong Answer e. Wrong Answer 70. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer d. Right Answer: That's the right answer e. Wrong Answer 71. Answers a. Wrong Answer b. Right Answer: That's the right answer c. Wrong Answer

d. Wrong Answer e. Wrong Answer 72. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Right Answer: That's the right answer 73. Answers a. Right Answer: That's the right answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 74. Answers a. Wrong Answer b. Wrong Answer c. Right Answer d. Wrong Answer e. Wrong Answer 75. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer d. Right Answer e. Wrong Answer 76. Answers a. Wrong Answer b. Right Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 77. Answers a. Wrong Answer b. Right Answer c. Wrong Answer

d. Wrong Answer e. Wrong Answer 78. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer d. Right Answer e. Wrong Answer 79. Answers a. Wrong Answer b. Wrong Answer c. Right Answer d. Wrong Answer e. Wrong Answer 80. Answers a. Right Answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 81. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Right Answer 82. Answers a. Wrong Answer b. Wrong Answer c. Right Answer d. Wrong Answer e. Wrong Answer 83. Answers a. Right Answer b. Wrong Answer c. Wrong Answer

d. Wrong Answer e. Wrong Answer 84. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer d. Right Answer e. Wrong Answer 85. Answers a. Wrong Answer b. Right Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 86. Answers a. Right Answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 87. Answers a. Wrong Answer b. Wrong Answer c. Right Answer d. Wrong Answer e. Wrong Answer 88. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Right Answer 89. Answers a. Wrong Answer b. Right Answer c. Wrong Answer

d. Wrong Answer e. Wrong Answer 90. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer d. Right Answer e. Wrong Answer 91. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer d. Right Answer e. Wrong Answer 92. Answers a. Right Answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 93. Answers a. Wrong Answer b. Right Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 94. Answers a. Wrong Answer b. Wrong Answer c. Right Answer d. Wrong Answer e. Wrong Answer 95. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer

d. Wrong Answer e. Right Answer 96. Answers a. Wrong Answer b. Wrong Answer c. Right Answer d. Wrong Answer e. Wrong Answer 97. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer d. Right Answer e. Wrong Answer 98. Answers a. Wrong Answer b. Right Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 99. Answers a. Wrong Answer b. Right Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 100. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Right Answer 101. Answers a. Wrong Answer b. Wrong Answer c. Right Answer

d. Wrong Answer e. Wrong Answer 102. Answers a. Wrong Answer b. Right Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 103. Answers a. Right Answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 104. Answers a. Wrong Answer b. Right Answer c. Right Answer d. Wrong Answer e. Wrong Answer 105. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer d. Right Answer e. Wrong Answer 106. Answers a. Right Answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 107. Answers a. Wrong Answer b. Wrong Answer c. Right Answer

d. Wrong Answer e. Wrong Answer 108. Answers a. Right Answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 109. Answers a. Right Answer b. Wrong Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 110. Answers a. Wrong Answer b. Wrong Answer c. Right Answer d. Wrong Answer e. Wrong Answer 111. Answers a. Wrong Answer b. Right Answer c. Wrong Answer d. Wrong Answer e. Wrong Answer 112. Answers a. Wrong Answer b. Wrong Answer c. Wrong Answer d. Right Answer e. Wrong Answer 113. Answers a. Right Answer b. Wrong Answer c. Wrong Answer

d. Wrong Answer e. Wrong Answer 114. Answers a. Wrong Answer b. Wrong Answer c. Right Answer d. Wrong Answer e. Wrong Answer 115. Answers a. Wrong Answer: Yes, it is possible to persist the value of a computed column b. Right Answer: The ask the database engine to store the value of a computed column, you must add the PERSISTED keyword c. Wrong Answer: There is no PERSIST keyword in Transact-SQL d. Wrong Answer: Persistence is not created as a constraint e. Wrong Answer: Persistence is not created as a constraint 116.

Previous

Copyright 2009-2011 FunctionX.com

Next

You might also like