You are on page 1of 2

use poavanzada

go
create table clientes(
id int,
nombre varchar (50),
telefono int,
apellido varchar (50),
correo varchar (50),
primary key (id))
go
select*from clientes
go
create proc sp_registrar
@id int,
@nom varchar(50),
@tel int,
@ape varchar (50),
@cor varchar (50)
as begin
insert into clientes values (@id,@nom,@tel,@ape,@cor)
end
go
create proc sp_mostrar
as begin
select*from clientes
end
go
create proc sp_buscar
@id int
as begin
select*from clientes where id=@id
end

create table produtos(


codigo int,
nombreproducto varchar (50),
proveedor varchar (50),
precio int,
primary key (codigo))
go
create proc pro_registrar
@cod int,
@nom varchar (50),
@pro varchar (50),
@pre int
as begin
insert into produtos values (@cod, @nom, @pro, @pre)
end
go
create proc pro_mostrar
as begin
select*from produtos
end
go
create proc produc_buscar

@cod int
as begin
select*from produtos where codigo=@cod
end
create proc Codigos
as begin
declare @nfactura char (5)
set @nfactura = (select MAX(nfactura)from dbo.facturar)
set @nfactura = 'C' +
RIGHT('000'+LTRIM(RIGHT(ISNULL(@nfactura,'000'),4)+1),4)
select @nfactura as nfactura
end

You might also like