GoConqr has a new look! Let us know what you think.

Quiz

SQL Quiz

R M 66 questions 5.0 (3 ratings)

Take the quiz

Questions in this quiz (66)

  1. 1Your database contains two tables named DomesticSalesOrders and InternationalSalesOrders. Both tables contain more than 100 million rows. Each table has a Primary Key column named SalesOrderId. The data
    in the two tables is distinct from one another. Business users want a report that includes aggregate information about the total number of global sales and total sales amounts. You need to ensure that your query executes in the minimum possible time. Which query should you use?
    1. A SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
      FROM (
      SELECT SalesOrderId, SalesAmount
      FROM DomesticSalesOrders
      UNION ALL
      SELECT SalesOrderId, SalesAmount
      FROM InternationalSalesOrders
      ) AS p
    2. BSELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
      FROM (
      SELECT SalesOrderId, SalesAmount
      FROM DomesticSalesOrders
      UNION
      SELECT SalesOrderId, SalesAmount
      FROM InternationalSalesOrders
      ) AS p
    3. C SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
      FROM DomesticSalesOrders
      UNION
      SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
      FROM InternationalSalesOrders
    4. DSELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
      FROM DomesticSalesOrders
      UNION ALL
      SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
  2. 2You are a database developer at an independent software vendor. You create stored procedures that contain proprietary code. You need to protect the code from being viewed by your customers. Which stored procedure option should you use?
    1. AENCRYPTBYKEY
    2. BENCRYPTION
    3. CENCRYPTBYPASSPHRASE
    4. DENCRYPTBYCERT
  3. 3You use a Microsoft SQL Server 2012 database. You want to create a table to store Microsoft Word documents. You need to ensure that the documents must only be accessible via Transact-SQL queries. Which Transact-SQL statement should you use?
    1. ACREATE TABLE DocumentStore
      (
      [Id] INT NOT NULL PRIMARY KEY, [Document] VARBINARY(MAX) NULL
      )
      GO
    2. B CREATE TABLE DocumentStore
      (
      [Id] hierarchyid,
      [Document] NVARCHAR NOT NULL
      )
    3. CCREATE TABLE DocumentStore AS FileTable
    4. DCREATE TABLE DocumentStore
      (
      [Id] [uniqueidentifier] ROWGUIDCOL NOT NULL UNIQUE, [Document] VARBINARY(MAX) FILESTREAM NULL
      )
      GO
  4. 4A table named Profits stores the total profit made each year within a territory. The Profits table has columns named Territory, Year, and Profit. You need to create a report that displays the profits made by each territory for each year and its preceding year. Which Transact-SQL query should you use?
    1. ASELECT Territory, Year, Profit,
      LAG(Profit, 1, 0) OVER(PARTITION BY Year ORDER BY Territory) AS
      NextProfit
      FROM Profits
    2. BSELECT Territory, Year, Profit,
      LAG(Profit, 1, 0) OVER(PARTITION BY Territory ORDER BY Year) AS
      NextProfit
      FROM Profits
    3. CSELECT Territory, Year, Profit,
      LEAD(Profit, 1, 0) OVER(PARTITION BY Territory ORDER BY Year) AS
      NextProfit
      FROM Profits
    4. DSELECT Territory, Year, Profit,
      LEAD(Profit, 1, 0) OVER(PARTITION BY Year ORDER BY Territory) AS
      NextProfit
      FROM Profits
  5. 5You use Microsoft SQL Server 2012 to develop a database application. Your application sends data to an NVARCHAR(MAX) variable named @var. You need to write a Transact-SQL statement that will find out the success of a cast to a decimal (36,9). Which code segment should you use?select
    1. ABEGIN TRY
      SELECT convert(decimal(36,9), @var) AS Value, ‘True’ AS BadCast
      END TRY
      BEGIN CATCH
      SELECT convert(decimal(36,9), @var) AS Value, ‘False’ AS BadCast
      END CATCH
    2. BTRY(
      SELECT convert(decimal(36,9), @var)
      SELECT ‘True’ AS BadCast
      )
      CATCH(
      SELECT ‘False’ AS BadCast
      )
    3. C SELECT CASE
      WHEN convert(decimal(36,9), @var) IS NULL THEN ‘True’
      ELSE ‘False’ END
      AS BadCast
    4. DSELECT
      IIF(TRY_PARSE(@var AS decimal(36,9)) IS NULL, ‘True’, ‘False’) AS BadCast
  6. 6You are writing a set of queries against a FILESTREAM-enabled database. You create a stored procedure that will update multiple tables within a transaction. You need to ensure that if the stored procedure raises a run-time error, the entire transaction is terminated and rolled back. Which Transact-SQL statement should you include at the beginning of the stored procedure?
    1. ASET TRANSACTION ISOLATION LEVEL SERIALIZABLE
    2. BSET XACT_ABORT OFF
    3. C SET TRANSACTION ISOLATION LEVEL SNAPSHOT
    4. D SET IMPLICIT_TRANSACTIONS ON
    5. ESET XACT_ABORT ON
    6. F SET IMPLICIT TRANSACTIONS OFF
  7. 7You have a Microsoft SQL Server 2012 database that contains tables named Customers and Orders. The tables are related by a column named CustomerID. You need to create a query that meets the following requirements:
    Returns the CustomerName for all customers and the OrderDate for any orders that they have placed. Results must include customers who have not placed any orders.
    Which Transact-SQL query should you use?
    1. ASELECT CustomerName, OrderDate
      FROM Customers
      RIGHT OUTER JOIN Orders
      ON Customers.CustomerID = Orders.CustomerID
    2. BSELECT CustomerName, CrderDate
      FROM Customers
      JOIN Orders
      ON Customers.CustomerID = Orders.CustomerID
    3. CSELECT CustomerName, OrderDate
      FROM Customers
      CROSS JOIN Orders
      ON Customers.CustomerID = Orders.CustomerID
    4. DSELECT CustomerName, OrderDate
      FROM Customers
      LEFT OUTER JOIN Orders
      ON Customers.CustomerID = Orders.CustomerID
  8. 8You create a stored procedure that will update multiple tables within a transaction. You need to ensure that if the stored procedure raises a run-time error, the entire transaction is terminated and rolled back. Which Transact-SQL statement should you include at the beginning of the stored procedure?
    1. ASET XACT_ABORT ON
    2. BSET ARITHABORT ON
    3. CTRY
    4. DBEGIN
    5. ESET ARITHABORT OFF
  9. 9You develop a Microsoft SQL Server 2012 database. You need to create a batch process that meets the following requirements:
    Status information must be logged to a status table.
    If the status table does not exist at the beginning of the batch, it must be created.
    Which object should you use?
    1. AScalar user-defined function
    2. BInline user-defined function
    3. CTable-valued user-defined function
    4. D Stored procedure
  10. 10You administer a database that includes a table named Customers that contains more than 750 rows. You create a new column named PartitionNumber of the int type in the table. You need to assign a PartitionNumber for each record in the Customers table. You also need to ensure that the PartitionNumber satisfies the following conditions:
    Always starts with 1.
    Starts again from 1 after it reaches 100. Which Transact-SQL statement should you use?
    1. AREATE SEQUENCE CustomerSequence AS int
      START WITH 0
      INCREMENT BY 1
      MINVALUE 1
      MAXVALUE 100
      UPDATE Customers SET PartitionNumber = NEXT VALUE FOR CustomerSequence
      DROP SEQUENCE CustomerSequence
    2. BCREATE SEQUENCE CustomerSequence AS int
      START WITH 1
      INCREMENT BY 1
      MINVALUE 1
      MAXVALUE 100
      CYCLE
      UPDATE Customers SET PartitionNumber = NEXT VALUE FOR CustomerSequence
      DROP SEQUENCE CustomerSequence
    3. CCREATE SEQUENCE CustomerSequence AS int
      START WITH 1
      INCREMENT BY 1
      MINVALUE 1
      MAXVALUE 100
      UPDATE Customers SET PartitionNumber = NEXT VALUE FOR CustomerSequence + 1
      DROP SEQUENCE CustomerSequence
    4. DCREATE SEQUENCE CustomerSequence AS int
      START WITH 1
      INCREMENT BY 1
      MINVALUE 0
      MAXVALUE 100
      CYCLE
      UPTATE Customers SET PartitionNumber = NEXT VALUE FOR CustomerSequence
      DROP SEQUENCE CustomerSequence

Information

Description
A collection of random questions and dumps
Author
R M
Language
English
Views
867
Rating
5.0 out of 5 · 3 ratings
Rate this quiz
Rate this quiz

Feedback

What is it about?

What do you think of the new look?

How do you like it?