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

  Search and set up the national parks database

create a table named Park. Accept the default ID primary key field with the AutoNumber data type, renaming it as Park ID. Enter at least five additional fields, such as Name, State, Fee, Hours

  Simulate the implementation of a real-life database

Simulate the implementation of a real-life database, you will start with requirements elicitation for a given scenario. After all the basic functional and non-functional requirements have been gathered, you will start designing the database.

  When would creating an index reduce overall database perform

Indexing can affect the performance of a general-purpose database that has roughly equal numbers of fetches and changes. The decision to add an index can improve the performance of a system but can also degrade it.

  Develop an erd for flyakite

Develop an ERD for FlyAKite

  Create a database to support the information management

Create a database to support the information management needs of an organization or individual. Explain why a database is a good tool to solve it. Describe what database features will be used and why. d. Provide background on the calculations, form..

  Create a student database in ruby

To create a student database in Ruby that allows for, updating a record within the database

  1 the appropriate sql statements for each query which

1. the appropriate sql statements for each query which should be copied from your sql code in mysql and pasted into

  Design a high-level conceptual view of a data warehouse

Design a high-level conceptual view of a data warehouse (DW) for Huffman Trucking using Microsoft Visio that shows the following: Integration layers

  Explain the need for key restructuring

Give at least three reasons why ETL functions are most challenging in a data warehouse environment.

  Question 1explain ten desirable features which may be

question 1explain ten desirable features which may be included in the design of a warehouse. question 2how have to a

  Design tables in 3nf various codes for at least three fields

Create tables in 3NF. As you create the database, include different codes for at least three of the fields. Use sample data to populate fields for at least three records in each table.

  How to use traditional database design method

Explain how you would follow three phases of traditional database design method (Hierarchical, Network, and Relational), considering the following scenario.

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