You are on page 1of 2

use pubs

go
--pregunta1
select * from dbo.employee
update dbo.employee set fname='PEDRO',lname='FUKUSAKI',hire_date='2004-01-10'
WHERE emp_id='H-B39728F'

select*from dbo.titles
update dbo.titles set price=price*1.20
where not pub_id=1389

select * from dbo.employee

--pregunta2
select*from dbo.stores
select*from dbo.NewStore

merge dbo.stores as target


using dbo.NewStore as source
on source.stor_id = target.stor_id
when not matched by target then
insert (stor_id,stor_name,stor_address,city,state,zip)
values
(source.stor_id,source.stor_name,source.stor_address,source.city,source.state,sou
rce.zip)

when matched then update set


target.stor_address=source.stor_address,
target.city=source.city

when not matched by source then delete;

--pregunta3
select*from dbo.titles

Create Function dbo.publishers (@p_pub_id varchar(4))


Returns Table
As
Return (Select
from as f join as DF
on =
where =
group by )
go
--pregunta5
create table dbo.AuditaEmployee(
emp_id char(9),
fname varchar(20),
minit char(1),
lname varchar(30),
job_id smallint,
job_lvl tinyint,
pub_id char(4),
hire_date datetime
)
go

select* from dbo.employee


select* from dbo.AuditaEmployee
go
INSERT INTO dbo.AuditaEmployee values('ppppppp', 'oleole', 'z', 'Cramer', 2, 215,
'9952', '11/12/20');
GO

create trigger TR_EmployeeActualizar


on dbo.employeefor update
as
declare @Id_emp char(9)
select @Id_emp = emp_id from inserted
insert into dbo.AuditaEmployee values('pphhhhhp', 'olettte', 'z', 'Cramer', 2,
215, '9952', '08/12/19')
go

You might also like