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: DELETE FROM Sales.Orders
WHERE OrderDate < ‘2012-01-01’ AND ShippedDate NOT NULL
References:
https://msdn.microsoft.com/en-us/library/ms189835.aspx
https://msdn.microsoft.com/en-us/library/bb630352.aspx