Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 . Write SELECT INTO statements to create two test tables named VendorCopy and InvoiceCopy that are complete copies of the Vendors and Invoices tables.

1.Write SELECT INTO statements to create two test tables named VendorCopy and InvoiceCopy that are complete copies of the Vendors and Invoices tables. If VendorCopy and InvoiceCopy already exist, first code two DROP TABLE statements to delete them.
2.Write an INSERT statement that adds a row to the InvoiceCopy table with the following values:
VendorID:32
InvoiceTotal:$434.58
TermsID:2
InvoiceNumber:AX-014-027
PaymentTotal:$0.00
InvoiceDueDate:07/8/16
InvoiceDate:06/21/16
CreditTotal:$0.00
PaymentDate:null
3.Write an INSERT statement that adds a row to the VendorCopy table for each non-California vendor in the Vendors table. (This will result in duplicate vendors in the VendorCopy table.)
4.Write and UPDATE statement that modifies the VendorCopy table. Change the default account number to 403 for each vendor that has a default account number of 400.
5.Write an UPDATE statement that modifies the InvoiceCopy table. Change the PaymentDate to today's date and the PaymentTotal to the balance due for each invoice with a balance due. Set today's date with a literal date string, or use the GETDATE() function.
6.Write an UPDATE statement that modifies the InvoiceCopy table. Change TermsID to 2 for each invoice that's from a vendor with a DefaultTermsID of 2. Use a subquery.
7.Solve exercise 6 using a join rather than a subquery.
8.Write a DELETE statement that deletes all vendors in the state of Minnesota from the VendorCopy table.
9.Write a DELETE statement for the VendorCopy table. Delete the vendors that are located in states from which no vendor has ever sent an invoice.
Hint: Use a subquery coded with "SELECT DISTINCT VendorState" introduced with the NOT IN operator. The subquery itself should return a list of states that DO have invoices. Then the outer query will delete Vendors not in those states

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions

Question

=+2 Why did OBI create Centers of Excellence?

Answered: 1 week ago