select * from tb_Borrower
begin tran
delete from tb_Borrower where BorrowerId=30
rollback tran
commit tran
create view rachel_test
as
select c.CategoryId,avg(TPrice) tprice, isnull(CName,’other’)cname
from tb_Title t
left join tb_Category c
on t.CategoryId=c.CategoryId
group by c.CategoryId,CName
select * from rachel_test
drop view rachel_test
declare @categoryname varchar(50)
set @categoryname = ‘romance’
select @categoryname
select *
from tb_Title t inner join tb_Category c
on t.CategoryId=c.CategoryId
where c.CName = @categoryname
declare @name varchar(50)
set @name = ‘rachel’
select @name
if exists(select * from dbo.tb_Borrower where BFirstName=@name)
begin
select @name+ ‘Is already exists in table’
end
else
begin
select @name+ ‘Is not in table’
end
declare @name varchar(50)
set @name = ‘bibi’
select @name
if exists(select * from dbo.tb_Borrower where BFirstName=@name)
begin
select @name+ ‘ Is already exists in table’
end
else
begin
select @name + ‘ Is not in table’
end
declare @name1 varchar(50)
set @name1 = ‘the lover’
declare @name2 varchar(50)
set @name2 = ‘Sinderella’
if exists(select * from tb_Title t where TName=@name1)
begin
Update tb_Title
set TPrice=TPrice *1.2
where TName=@name1
end
else
begin
insert into tb_Title values(@name1,1,1,10,null)
end
if exists(select * from tb_Title t where TName=@name2)
begin
Update tb_Title
set TPrice=TPrice + 1.2
where TName=@name2
end
else
begin
insert into tb_Title values(@name2,1,1,10,null)
end