Question

sql server please help me>>> Create a stored procedure called uspRetrieveOrders that returns all the orders...

sql server

please help me>>>

Create a stored procedure called uspRetrieveOrders that returns all the orders for a last name. It should return first name, last name, item price, discount amount, quantity, the line item extended amount ((ItemPrice-DiscountAmount)*Quantity), the tax amount, and the card type. It should accept LastName as a parameter. Include logic to test if the customer exists in the database. If not, generate an error message. Show the code you used to test the proc.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CREATE PROCEDURE uspRetrieveOrders
(
@lastname VARCHAR(20)
)
AS
BEGIN
IF EXISTS (SELECT * FROM Customer WHERE LastName=@lastname)
BEGIN
SELECT firstname, lastname, itemprice, discountamount, quantity,
((ItemPrice-DiscountAmount)*Quantity) AS ItemExtendedAmount,taxamount,cardtype
FROM Orders WHERE lastname=@lastname
END
ELSE
BEGIN
RETURN 'Not Found'
END
END

Add a comment
Know the answer?
Add Answer to:
sql server please help me>>> Create a stored procedure called uspRetrieveOrders that returns all the orders...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The following question uses Microsoft SQL Server. Create a simple stored procedure that does not expect...

    The following question uses Microsoft SQL Server. Create a simple stored procedure that does not expect any parameters and contains a single T-SQL statement. Create the stored procedure as PurchaseOrderInfo This stored Procedure should return a result set consisting of ProductName, PurchaseOrderID, PurchaseOrderDetailID, OrderDate, TotalDue and ReceivedQty. Refer to the schema AdventureWorks2012.Production and AdventureWorks2012.Purchasing to access the necessary tables needed to generate the following output. EXECUTE the stored procedure in 2 ways. Using the simple EXECUTE keyword, and Using EXECUTE...

  • How can I create the following stored procedure in MySQL Workbench?: Create a stored procedure na...

    How can I create the following stored procedure in MySQL Workbench?: Create a stored procedure named prc_new_rental to insert new rows in the RENTAL table. The procedure should satisfy the following conditions: a. The membership number will be provided as a parameter. b. Use a Count() function to verify that the membership number exists in the MEMBERSHIP table. If it does not exist, then a message should be displayed that the membership does not exist and no data should be...

  • Create the following SQL Server queries that access the Northwind database Same as problem 3 but,...

    Create the following SQL Server queries that access the Northwind database Same as problem 3 but, limit the list to all customers who placed 3 or more orders. The product id, product name, last date that the product was ordered for all items in the Grains/Cereals category. (Hint: Use MAX) The product ID, product name, and number of distinct customers who ordered that product in 1996 Thank you. Categories Customers Employees Order Details Orders Products Shippers 9 CategoryID CategoryName Description...

  • need help Create or edit the SQL statements required to accomplish the following tasks. All columns...

    need help Create or edit the SQL statements required to accomplish the following tasks. All columns should have a column name, feel free to create appropriate aliases Use screen shots to ca evidence that each task is completed; include the SQL records before and after statements are executed, as appropriate. Include all work, even if you get errors. Paste your screen shots into a single PowerPoint file pture statements output from the statements, and views of the object explorer when...

  • Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the p...

    Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the publisher contact for each book using JOIN...USING clause. Write a query to show the first and last names of customers who have ordered cooking books. Use the WHERE clause to join the tables. Write a query to show the title, cost and ISBN of each book in the books table. If the book has been ordered,...

  • I've done all questions except question 6. how do I do this? please help. code needs...

    I've done all questions except question 6. how do I do this? please help. code needs to be java 1. You need to be able to open and read the text files that have been provided for the project. Write a Java program that reads the driver.txt file and displays each data value for each line from the file to the screen in the following format: Licence Number: Licence Class: First Name: Last Name: Address: Suburb: Postcode: Demerit Points: Licence...

  • An online company sells hundreds of office supply products on its e-Commerce store. It has asked...

    An online company sells hundreds of office supply products on its e-Commerce store. It has asked you to design and implement a sales order processing system which will be used by users in our Operations department to process sales orders. Here is an overview of the sales order process. Customers make purchases by placing orders. Each customer has a customer number and profile (such as name, shipping address). To simplify the matter, each time an order is placed, only one...

  • hello there, i have to implement this on java processing. can someone please help me regarding...

    hello there, i have to implement this on java processing. can someone please help me regarding that? thanks War is the name of a popular children’s card game. There are many variants. After playing War with a friend for over an hour, they argue that this game must never end . However! You are convinced that it will end. As a budding computer scientist, you decide to build a simulator to find out for sure! You will implement the logic...

  • Please explain each line of code, all code will be in Java. Thank you JKL Restaurant...

    Please explain each line of code, all code will be in Java. Thank you JKL Restaurant maintains a members’ club for its customers.  There are three levels of membership: (1) Basic, (2) Silver, and (3) Gold. A certain member has to be exactly a Basic, Silver, or Gold member at any point in time.  Whenever a member spends money at JKL, he/she gets points and as these points are accumulated, one can redeem one or more $20 dining certificates.  Each Gold member can...

  • This is about database system. Thank you. Question B1 Create a Crow's Foot ERD with the...

    This is about database system. Thank you. Question B1 Create a Crow's Foot ERD with the business rules described below. Write all appropriate connectivities and cardinalities in the ERD. A music store would like to develop a database to manage information about the CDs, or vinyl collection, the customers and transactions information. It stores the relationships between artists, albums, tracks, customers and transactions. Here is the list of requirements for the database: The collection consists of albums. An album is...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT