PrepAway - Latest Free Exam Questions & Answers

Which Transact-SQL query should you use?

Your database contains a table named Purchases. The table includes a DATETIME column named
PurchaseTime that stores the date and time each purchase is made. There is a non- clustered index on the
PurchaseTime column. The business team wants a report that displays the total number of purchases made on
the current day. You need to write a query that will return the correct results in the most efficient manner.
Which Transact-SQL query should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
SELECT COUNT(*)
FROM Purchases
WHERE PurchaseTime = CONVERT(DATE, GETDATE())

B.
SELECT COUNT(*)
FROM Purchases
WHERE PurchaseTime = GETDATE()

C.
SELECT COUNT(*)
FROM Purchases
WHERE CONVERT(VARCHAR, PurchaseTime, 112) =
CONVERT(VARCHAR, GETDATE(), 112)

D.
SELECT COUNT(*)
FROM Purchases
WHERE PurchaseTime >= CONVERT(DATE, GETDATE())
AND PurchaseTime <DATEADD(DAY, 1, CONVERT(DATE, GETDATE()))

Explanation:
To compare a time with date we must use >= and > operators, and not the = operator.
Incorrect Answers:
A: The in WHERE clause there is an incorrect comparison between time and a date, as equality (=) is used.

http://technet.microsoft.com/en-us/library/ms181034.aspx

18 Comments on “Which Transact-SQL query should you use?

  1. Runing Man says:

    New 70-765 Exam Questions and Answers (Updated at 7th/12/2017)

    QUESTION
    You administer two Microsoft SQL Server 2012 servers. Each server resides in a different, untrusted domain.
    You plan to configure database mirroring.
    You need to be able to create database mirroring endpoints on both servers.
    What should you do?

    A. Configure the SQL Server service account to use Network Service.
    B. Use a server certificate.
    C. Use a database certificate.
    D. Configure the SQL Server service account to use Local System.

    Answer: B

    QUESTION
    You administer a Microsoft SQL Server 2012 instance that has several SQL Server Agent jobs configured.
    When SQL Server Agent jobs fail, the error messages returned by the job steps do not provide the required detail.
    The following error message is an example error message:
    “The job failed. The Job was invoked by User CONTOSO\ServiceAccount. The last step to run was step 1 (Subplan_1).”
    You need to ensure that all available details of the job step failures for SQL Server Agent jobs are retained.
    What should you do?

    A. Configure output files.
    B. Expand agent logging to include information from all events.
    C. Disable the Limit size of job history log feature.
    D. Configure event forwarding.

    Answer: B

    QUESTION
    You administer a Microsoft SQL Server 2012 instance.
    You need to configure a new database to support FILETABLES.
    What should you do? Choose all that apply.

    A. Disable FILESTREAM on the Database.
    B. Enable FILESTREAM on the Server Instance.
    C. Configure the Database for Partial Containment.
    D. Create a non-empty FILESTREAM file group.
    E. Enable Contained Databases on the Server Instance.
    F. Set the FILESTREAM directory name on the Database.

    Answer: BDF

    QUESTION
    You administer two instances of Microsoft SQL Server 2012.
    You deploy an application that uses a database on the named instance.
    The application is unable to connect to the database on the named instance.
    You need to ensure that the application can connect to the named instance.
    What should you do?

    A. Configure the application as data-tiered.
    B. Open port 1433 on the Windows firewall on the server.
    C. Configure the named SQL Server instance to use an account that is a member of the Domain Admins group.
    D. Start the SQL Server Browser Service.

    Answer: D

    More NEW 70-765 Exam Questions: https://www.braindump2go.com/70-765.html




    0



    0
  2. kumar says:

    4. you have a database named DB1 that contains a table named Table1. Tanlbe1 has a non-clustered index named index1.
    You discover that index1 is corrupt.
    You need to repair index1.
    Which statement should you execute?
    A. DBCC CHECKDB (‘db1’, REPAIR_FAST)
    B. ALTER INDEX indx1 ON table1 REBUILD WITH (ONLINE-ON)
    C. ALTER INDEX index1 ON table1 REORGANIZE
    D. DBCC CHECKDB (‘db1’, DATA_PURITY)
    5. you have a database named DB1 AND APPLICATION NAMED App1. App1 queries DB1.
    You discover that a non-clustered index in DB1 is corrupt.
    You need to repair the index. App1 must be able to query DB1 while the index is being repaired.
    What should you do?
    A. Run CHECKDB REPAIR DATABASE and specify the REPAIR_REBUILD parameter.
    B. Restore DB1 from a backup.
    C. Run CHECKDB REPAIR DATABASE and specify the ALLOW_DATA_LOSS parameter.
    D. Drop and recreate the index.
    6. you have Microsoft SQL server on a Microsoft Azure virtual machine. The virtual machine has 200 GB of data.
    User report a slow response time when quering the database.
    You need to identify whether the storage subsystem causes the performance issue.
    Which performance monitor counter should you view?
    A. Data sec/Write
    B. Avg.disk Read Queue Length
    C. % Disk Read Time
    D. Disk sec/Read




    0



    0

Leave a Reply