What does the exec above produce in terms of results

Assignment Help Database Management System
Reference no: EM13854419

Part -1:

Question 1:

Rewrite this stored procedure to use Try-Catch block instead of the IF @@error method).

This example creates the AddSupplierProduct stored procedure that uses the @Oerror function to determine whether an error occurs when each INSERT statement is executed. If the error does occur, the transaction is rolled back.

https://queriesmssql.wordpress.comicategory/ad-hoc-queries/page/4/
USE Northwind
GO

CREATE PROCEDURE AddSupplierProduct
@CompanyName nvarchar (40) NULL,
@ContactName nvarchar (40) NULL,
@ProductName nvarchar (40) NULL,
@CategorylD int NULL,
@QuantityPerUnit nvarchar(20) NULL,
@Discontinued bit - NULL

AS
BEGIN TRANSACTION
INSERT Suppliers (CompanyName, ContactName)
VALUES (@CompanyName, @ContactName)
IF @@error <> 0
BEGIN
ROLLBACK TRAN
RETURN
END
DECLARE @InsertSupplierlD int
SELECT @InsertSupplierlDm@@identity
INSERT Products (ProductName, SupplierlD, CategorylD, QuantityPerUnit, Discontinued) VALUES (@ProductName, @InsertSupplierlD, @CategorylD, @QuantityPerUnit, @Discontinued)

IF @@error <> 0
BEGIN
ROLLBACK TRAN
RETURN
END
COMMIT TRANSACTION
/*
Note:

SupplierlD is auto-generated (Identity property is set to True) so it is not needed.

All the columns in the Suppliers table with the exception of CompanyName allow a null value.

All the columns in the Products table with the exception of ProductlD allow a null value including the two Foreign Keys of SupplierlD and CategorylD. If a SupplierlD or a CategorylD is given then it must exist in the corresponding table. The SupplierlD in this case is picked up from the @InsertSupplierlD. */

Question 2:

Create a stored procedure that allows me to enter the CustomerlD as a parameter and returns the CustomerlD and CompanyName.

Question 3:

The option is only needed if it is possible the query plan needed to be updated each time the stored procedure is executed.
• update
• re-execute
• recompile

• return

Part -2:

Create the following stored procedure (from Chapter 15 Exercise 1):
CREATE PROC spBalanceRange @VendorVar varchar(50) = 196', @BalanceMin money = 0, @BalanceMax money = 0
AS
SELECT VendorName
, InvoiceNumber
, InvoiceTotal - CreditTotal - PaymentTotal AS Balance
FROM Vendors JOIN Invoices ON Vendors.VendorlD = Invoices.VendorlD
WHERE VendorName LIKE @VendorVar
AND (InvoiceTotal - CreditTotal - PaymentTotal) BETWEEN @BalanceMin AND @BalanceMax ORDER BY Balance DESC;

Question 1:

EXEC spBalanceRange 'M%'

What does the exec above produce in terms of results. If you wanted companies that had 'Corp' in their name how would you code the EXEC statement?

Question 2:

EXEC spBalanceRange @BalanceMin = 200, @BalanceMax = 1000

What does the exec above produce in terms of results. What would happen it you miss coded the maximum balance to be 100 instead?

Question 3:

EXEC spBalanceRange [C,F]%, 0, 200

What does the exec above produce in terms of results. How would you code an EXEC statement to bring back those vendors whose name begin with the letter A thru L with a minimum balance of 100 and a maximum balance of 500?

Reference no: EM13854419

Questions Cloud

What is uncontrollable for hiking and conservation : What is uncontrollable for hiking and conservation? What do people need to do? What are the most important things you can do before a hike or going out doors for some adventure?
Defines a level curve through a point : The equation f(x,y) = f(a,b) defines a level curve through a point (a, b) where grad f (a, b) à= ì0 . Use im- plicit differentiation and the chain rule to show that the slope of the line tangent to this curve at the point (a, b) is !fx(a,b)/fy(a,b) i..
How is she a good saudi designer : Write just 2 paragraph- The first paragraph about her, how is she a good saudi designer, saudi women are stylish and her stores
In what way is per capita gdp a better measure of economic : In what way is Per Capita GDP a better measure of economic well being than GDP?
What does the exec above produce in terms of results : What does the exec above produce in terms of results. If you wanted companies that had 'Corp' in their name how would you code the EXEC statement - What does the exec above produce in terms of results. What would happen it you miss coded the maxim..
Compare and contrast the plots of the stories : Compare and contrast the plots of the stories and the significance for theintended audiences. What sorts of assumptions or biases might audiences who are not the target audiences draw from these stories
Why sas institute has a positive organization climate : Essay of 600 words of why SAS Institute has a positive organization climate, and how they encourage it.  Do in APA format and 3 credited references
Multilateral net settlement system is used for interbank pay : When a multilateral net settlement system is used for interbank payments, transactions are processed. In a gross settlement system, by contrast, transactions are processed.
The culture in your company emphasizes making money : The culture in your company emphasizes making money more than it does safety.  However, you know that a safe workplace will save the firm money in the short run and the long run.  How would you make a case to senior management that developing a cultu..

Reviews

Write a Review

Database Management System Questions & Answers

  Show all the lastnames from the customers table

Show all the LastNames from the Customers table and any associated OrdersIDs from the Orders Table.

  Determine the steps in development of an effective entity

Determine the steps in the development of an effective Entity Relationship Model (ERM) Diagram and determine the possible iterative steps / factors that one must consider in this process with consideration of the HR core functions and responsibili..

  Object-oriented databases

Object-oriented databases, Write a paper that describes the topic in detail. Include descriptions covering the following subject areas

  Develop a domain model for the case study

The objective of the assignment is to apply and consolidate skills acquired in the requirement and analysis disciplines through analysis of a simple case study, and to express the results through the relevant UML diagrams.

  Create microsoft access database for doc-n-the-box pharmacy

Create a Microsoft Access database for the Doc-n-the-Box pharmacy. Create the table(s), field(s), data type(s), primary key(s), etc. for the database

  What about your experience was most confusing or frustrating

What about your experience was most confusing or frustrating? What important journals, key scholars, or new ideas did you discover from your search?

  How many records are returned using minus operator

Customers Dunne an Olowski are included in the CUSTOMER table also in CUSTOMER_2 table. Explain How many records are returned when using the MINUS operator?

  An er diagram for the system

An ER diagram for the system. Show all entities, relationships, cardinalities and optionalities. Also, include all intersection entities. You must use the Finkelstein methodology as per the study book and tutorials.

  Give a list of employee names

Using the Northwind database - Give a list of employee names and each employee's corresponding customers by company name.

  A uml class diagram to describe the ordering system class

a UML class diagram to describe the ordering system class

  Explain issues to convert relationship for new cardinality

Using example of vehicles and drivers, explain issues to convert relationship for new cardinality including new relationships and attributes for the tables.

  Managing information and databse

Write 7 page about managing information and databse

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd