Documentos de Académico
Documentos de Profesional
Documentos de Cultura
begin try
print 167/0
end try
/*iniciamos la captura de error, terminamos la captura de error*/
begin catch
print 'ocurrio un error: ' + error_message()
end catch
begin try
declare @peso int
set @peso = 'once'
print @peso
end try
begin catch
select ERROR_NUMBER(), 'error al leer el numero', ERROR_MESSAGE()
end catch
begin try
declare @valor1 numeric(8,2),@valor2 numeric(8,2), @division numeric(8,2)
set @valor1 = 50
set @valor2 = 0
set @division = @valor1/@valor2
PRINT 'La division no reporta error'
end try
begin catch
select ERROR_NUMBER() as 'N° de error', ERROR_SEVERITY() as 'Severidad',
ERROR_STATE() as 'Estado',
ERROR_PROCEDURE() as 'Procedimiento', ERROR_LINE() as 'N° de linea', ERROR_MESSAGE()
as 'Mensaje'
end catch
begin try
declare @multiplicando int ,
@multiplicacion int ,
@resultado int
set @multiplicacion = 50
set @multiplicando = 0
begin try
execute listaproductos
end try
begin catch
select ERROR_NUMBER() as 'N° Error', ERROR_MESSAGE() as 'Mensaje'
end catch
/*BD Northwind
en esta BD los pedidos se envian a traves de tres compañias de transportes: Speedy
Express(1)
United Package(2) y federal Shipping(3). la compañia federal Shipping nos oferta
realizar todo los envios
que hacemos a traves de United Package el precio fijo es de 10$ se decide cambiar
todos los pedidos abiertos
que tienen que ser enviados por United Package para que sean enviados a traves de
federal shipping y aprovechar las
ofertas*/
use Northwind
go
declare @nt datetime
set @nt=GETDATE()
create table #actualizar1 (OrderID int, ShipVia int, Freight money)
insert into #actualizar1 select OrderID, ShipVia, Freight
from Orders where ShipVia=2 and ShippedDate is null
update Orders set ShipVia=3, Freight=10 where OrderID in (select OrderID from
#actualizar1)drop table #actualizar1
print 'operacion completada en: ' + rtrim(cast(datediff(ms,@nt,getdate()) as
char(10)))
+ ' milisegundos'