exam questions

Exam 70-761 All Questions

View all questions & answers for the 70-761 exam

Exam 70-761 topic 1 question 25 discussion

Actual exam question from Microsoft's 70-761
Question #: 25
Topic #: 1
[All 70-761 Questions]

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.

Show Suggested Answer Hide Answer
Suggested Answer: See the solution below
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

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Houdinni
Highly Voted 5 years, 9 months ago
DELETE FROM Sales.Orders WHERE OrderDate < '20120101' AND ShippedDate IS NOT NULL
upvoted 33 times
det
5 years, 1 month ago
with a small correction: dbo.Sales.Orders because of "use one-part column names and two-part table names"
upvoted 2 times
Olayemi87
5 years, 1 month ago
This is misleading. Sales.Orders is already a 2 part table name which consist of both the SchemaName.TableName.
upvoted 9 times
...
...
...
Andy7622
Most Recent 4 years, 5 months ago
Should be 'ShippedDate IS NOT NULL' instead of 'ShippedDate NOT NULL'
upvoted 1 times
...
ASQL
4 years, 7 months ago
drop table if exists Orders Create Table Orders ( OrderID int not null, OrderDate date null, ShippedDate date null, Status varchar(20), Constraint PK_Orders primary key clustered (OrderID) ) insert into Orders values (1011,'2020-05-14','2020-05-25','Shipped'),(1012,'2018-02-04','2020-01-25','Shipped'),(1017,'2011-05-14','2011-12-18','Shipped'), (1013,'2017-01-14','2018-01-05','Cancelled'),(1014,null,'2020-12-25','Pending'),(1015,'2000-11-14',null,'Shipped'),(1016,'2011-05-14',null,'Shipped') delete from dbo.Orders where OrderDate < '20120101' and ShippedDate is not null
upvoted 4 times
...
Anette
4 years, 12 months ago
or can be ShippedDate < GETDATE() instead of ShippedDate IS NOT NULL
upvoted 1 times
Ricky7876
4 years, 12 months ago
But it says not to use functions. Additionally, I wonder what the Status column consists of... Perhaps we could use Status = 'Shipped'
upvoted 3 times
Oooo
4 years, 7 months ago
No we have to go with Shippeddate column. As we are just working with the definition of the column, we never know what values the column Status holds.(Ex it could be 'Shipped' or 'Yes' or '1' or anything.)
upvoted 1 times
Oooo
4 years, 7 months ago
**definition of the table
upvoted 1 times
...
...
...
...
fabzo
5 years, 6 months ago
I think both would be correct "IS NOT NULL" or "NOT NULL"
upvoted 3 times
Barbedx
5 years, 2 months ago
No, sql don't have command "not null" only "is not null" Also, we need use YYYYMMDD Format, like Houdinni says - '20120101'
upvoted 5 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago