go
log on
(name=sis_bd_log,
filename='D:/sis_bd.ldf',
size=10mb,
maxsize=20mb,
filegrowth=2mb
)
go
use sis_bd
go
use sis_bd
create table Cliente
(cod_cli varchar(10) not null primary key(cod_cli),
ruc char(11) not null,
ape_nomcli varchar(50) not null,
dni_cli char(8) not null,
dir_cli varchar(30) not null)
go
use sis_bd
create table Factura
(nrofac char(8) not null primary key(nrofac),
cod_cli varchar(10) not null,
fecha_fac date not null,
total float not null)
go
select*from Cliente
select*from Factura
--ejemplo 01
--declaracion de variables
declare @nombre varchar(35)
declare @N1 int,@N2 int, @N3 int, @N4 int,@promedio decimal(5,2)
---asignacion de variables
set @nombre='vilma quispe ramos'
set @N1=14
set @N2=15
set @N3=10
set @N4=8
---CALCULANDO EL PROMEDIO
set @promedio=((@N1+@N2+@N3+@N4)/4.0)
---MOSTRAR LOS RESULTADOS
print 'los resultados es:'
print '--------------------------'
print 'nombre:'+@nombre
print 'Nota 1:'+ cast(@N1 as char (2))
print 'Nota 2:'+ cast(@N2 as char (2))
print 'Nota 3:'+ cast(@N3 as char (2))
print 'Nota 4:'+ cast(@N4 as char (2))
print '**************************'
print 'el promedio es:'+ cast (@promedio as char (5))
go
--ejemplo 02
Declare @fac char(8)='0003'
Declare @cliente varchar(50)
select @cliente=ape_nomcli
from Factura join Cliente on Cliente.cod_cli=Factura.cod_cli where nrofac=@fac
print'***R E S P U E S T A***'
print'------------------'
print'La factura con nro :'+@fac
print 'tiene como cliente a:'+ @cliente
go
----ejemplo 03
declare @t_mayor float
select @t_mayor=max(total) from Factura
select*from Factura
where total=@t_mayor
go
---ejemplo 04
declare @udea varchar(45)
set @udea='D%'
SELECT ape_nomcli
from Cliente
where ape_nomcli like @udea
go