SIMULATION
You create a table named Sales.Orders by running the following Transact-SQL statement:
You need to write a query that meets the following requirements:
removes orders from the table that were placed before January 1, 2012
uses the date format of YYYYMMDD
ensures that the order has been shipped before deleting the record
Construct the query using the following guidelines:
use one-part column names and two-part table names
do not use functions
do not surround object names with square brackets
do not use variables
do not use aliases for column names and table names
Part of the correct Transact-SQL has been provided in the answer area below. Enter the code in the answer
area that resolves the problem and meets the stated goals or requirements. You can add code within the code
that has been provided as well as below it.
Use the Check Syntax button to verify your work. Any syntax or spelling errors will be reported by line and
character position.
Answer: See the explanation
Explanation:
DELETE FROM Sales.Orders
WHERE OrderDate < ‘2012-01-01’ AND ShippedDate NOT NULLhttps://msdn.microsoft.com/en-us/library/ms189835.aspx
https://msdn.microsoft.com/en-us/library/bb630352.aspx
Seriously ShippedDate NOT NULL ? what a joke …
Should be IS NOT NULL. Otherwise correct.
Question specifies date format of “YYYYMMDD”
Answer is wrong as it has a date of format “YYYY-MM-DD”
delete from Sales.Orders
where OrderDate < Convert(date, '20120101')
and ShippedDate IS NOT NULL