Question: Urgent 1. The code below contains errors. Can you please correct the errors so that the procedure can execute successfully. ALTER PROCEDURE dbo.AddSale @employeeid INT,

Urgent

1. The code below contains errors. Can you please correct the errors so that the procedure can execute successfully.

ALTER PROCEDURE dbo.AddSale @employeeid INT,

@productid INT,

@quantity SMALLINT,

@saleid UNIQUEIDENTIFIER OUTPUT

AS

SET @saleid = NEWID

TRY

INSERT Sales.Sales

@saleid,

@productid,

@employeeid,

@quantity

TRY

CATCH

INSERT INTO dbo.DB_Errors

(SUSER_SNAME(),

ERROR_NUMBER(),

ERROR_STATE(),

ERROR_SEVERITY(),

ERROR_LINE(),

ERROR_PROCEDURE(),

ERROR_MESSAGE(),

GETDATE());

CATCH

GO

2.

Can you please explain the following code?

BEGIN TRY
 DECLARE @x int
 SELECT @x = 1/0
 PRINT 'This statement will not be executed'
END TRY
BEGIN CATCH 
 PRINT 'The error message is: ' + error_message()
END CATCH

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!