Se quiere actualizar los stocks de productos de acuerdo al siguiente crite
rio: - Si las unidades en stock del producto es menor a 10 unidades se debe increment ar el stock en un 50%. - Si las unidades en stock del producto es mayor o igual a 10 unidades pero meno r a 40 se debe incrementar en un 25%. - Si las unidades en stock del producto es mayor o igual a 40 unidades se debe s olo incrementar en el promedio entre el máximo y mínimo stock de productos. Diseñe un procedimiento almacenado para dar solución a esta problemática teniendo en c uenta la validación respectiva de si existe el producto.*/ create procedure SP_ACTUALIZAR_STOCK @Producto varchar(150) as declare @var varchar(150) select @var=ProductName from Products where ProductName=@Producto if @var=@Producto begin declare @Stock smallint select @Stock=UnitsInStock from Products where ProductName=@Producto if @Stock<10 begin select ProductName,UnitsInStock from Pro ducts where ProductName=@Producto update Products set UnitsInStock=UnitsInStock + (Uni tsInStock*0.50) where ProductName=@Producto select ProductName,UnitsInStock from Pro ducts where ProductName=@Producto end if @Stock>=10 and @Stock<40 begin select ProductName,UnitsInStock from Pro ducts where ProductName=@Producto update Products set UnitsInStock=UnitsInStock + (Uni tsInStock*0.25) where ProductName=@Producto select ProductName,UnitsInStock from Pro ducts where ProductName=@Producto end if @Stock>=40 declare @Prom smallint select @Prom=(max(UnitsInStock)+ min(UnitsInStock))/2 fr om Products Print @Prom begin select ProductName,UnitsInStock from Pro ducts where ProductName=@Producto update Products set UnitsInStock=UnitsInStock+@Prom where ProductName=@Producto select ProductName,UnitsInStock from Pro ducts where ProductName=@Producto end end else begin Print 'El Producto No Existe' Print 'Debe registrarlo' end /*13. Cree un procedimiento almacenado que permita al momento de ejecutarse crea r una tabla temporal donde se cargaran las ventas totales de cada empleado, se debe validar antes de crearla que no exista dicha tabla en la Base de Datos.*/ create procedure SP_TEMPORAL as if exists (select * from SysObjects where Type='U' and Name='Temporal') begin print 'la tabla ya esxiste' drop table Name (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Temporal' ) end else begin print 'Tabla Eliminada y Creada' select e.EmployeeID,count(o.OrderID) as [Ventas Totales] into Te mporal from Employees e inner join Orders o on e.EmployeeID=o.EmployeeID group by e.EmployeeID end