You are on page 1of 3

--numero 1 de transaccion

select * from Sales.Customer order by CustomerID desc

create proc AddCustomer @IdPersona int,@idTerritorio int


as
begin
begin try
begin tran
insert into Sales.Customer values
(@IdPersona,NULL,@idTerritorio,NEWID(),GETDATE())
commit tran
end try
begin catch
rollback
print 'no se pudo registrar el cliente'
end catch
end

exec AddCustomer 1997,4

--numero 2 de transaccion--

exec AddProduct 'vaso','VS-


9874','adquirido','vendible','blanco',1500,500,20.00,40.00,NULL,NULL,NULL,NULL,0,NU
LL
,NULL,NULL,NULL,NULL;
go

select * from Production.Product order by ProductID desc

alter proc AddProduct @name nvarchar(50),@ProNumber nvarchar(25),@MakeF


nvarchar(10),@FinishedF nvarchar(12),@color nvarchar(15)=NULL,
@LevelStock smallint,@NivelPedido
smallint,@StandCost money,@OutPrice money,@Size nvarchar(5)=NULL,
@SizeUnit nchar(3)=NULL,@WeightUnit
nchar(3)=NULL,@weight decimal(8,2)=NULL,@Days int,@ProLine varchar(10)=NULL,
@Class nvarchar(5)=NULL,@Style
nvarchar(10)=NULL,@ProSubCat int=NULL,@ProModel int=NULL
as
begin
begin try
begin tran
declare @MakeFlag bit,@FinishedGoodFlag bit
if @MakeF = 'hecho'
begin
set @MakeFlag = 1;
end
else
begin
set @MakeFlag = 0;
end
if @FinishedF = 'vendible'
begin
set @FinishedGoodFlag = 1;
end
else
begin
set @FinishedGoodFlag = 0;
end

insert into Production.Product (


[Name]
,[ProductNumber]
,[MakeFlag]
,[FinishedGoodsFlag]
,[Color]
,[SafetyStockLevel]
,[ReorderPoint]
,[StandardCost]
,[ListPrice]
,[Size]
,[SizeUnitMeasureCode]
,[WeightUnitMeasureCode]
,[Weight]
,[DaysToManufacture]
,[ProductLine]
,[Class]
,[Style]
,[ProductSubcategoryID]
,[ProductModelID]
,[SellStartDate]
,[SellEndDate]
,[DiscontinuedDate]
,[rowguid]
,[ModifiedDate])
VALUES
(@name
,@ProNumber
,@MakeFlag
,@FinishedGoodFlag
,@color
,@LevelStock
,@NivelPedido
,@StandCost
,@OutPrice
,@Size
,@SizeUnit
,@WeightUnit
,@weight
,@Days
,@ProLine
,@Class
,@Style
,@ProSubCat
,@ProModel
,GETDATE()
,NULL
,NULL
,NEWID()
,GETDATE())

commit tran
end try
begin catch
rollback
print 'no se aadio el producto'
end catch
end
go

You might also like