1. Write a CREATE VIEW statement that defines a view named InvoiceBasic that ret
ID: 3546898 • Letter: 1
Question
1. Write a CREATE VIEW statement that defines a view named InvoiceBasic that returns three columns: VendorName, InvoiceNumber, and InvoiceTotal. Then, write a SELECT statement that returns all of the columns in the view, sorted by VendorName, where the first letter of the vendor name is N, O, or P.
3. Create an updatable view named VendorAddress that returns the VendorID, both address columns, and the city, state and zip code columns for each vendor. Then, write a SELECT query to examine the result set where VendorID=4. Next, write an UPDATE statement that changes the address so that the suite number (Ste 260) is stored in VendorAddress2 rather than in VendorAddress1. To verify the change, rerun your SELECT query.
4. Write a SELECT statement that selects all of the columns for the catalog view that returns information about foreign keys. How mant foreign keys are defined in the AP database?
5. Using the Management Studio, modify the InvoiceBasic view created in exercise 1 to sort the result set by VendorName. What clause does the system automatically code to allow the use of an ORDER BY clause in the view?
Explanation / Answer
Answer 1
CREATE VIEW InvoiceBasic
AS
SELECT VendorName, InvoiceNumber, InvoiceTotal
FROM table_name
SELECT * FROM
InvoiceBasic
where
vendorName LIKE 'N%'
OR vendorNameLIKE 'O%'
OR vendorNameLIKE 'P%'
order byvendorName
Answer 2
CREATE VIEW VendorAdress
AS
SELECT VendorID, Address1, addres2, city, state, zipcode
from tablename
SELECT * FROM
VendorAdress
where VendorID=4
UPDATE VendorAdress
SET VendorAddress2 = VendorAdress1
WHERE VendorID = 4
Answer 3 :
SELECT * from sys.foreign_keys
Other Questions are Management Studio specific so I didnt had the answer to those questions
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.