--(1)创建包含Goods表中“热点”商品的视图vw_HotGoods。
--create view vw_HotGoods
--as
--select *
--from Goods
--where g_Status='热点'
--(2)在视图vw_HotGoods中查询价格在2500元以上的商品信息。
----select *
----from vw_HotGoods
----where g_Price>2500
--(3)在视图vw_HotGoods中将名称为“飞利浦292”的商品的折扣修改为0.75,修改完成后,查看源表的数据有何变化。
--update vw_HotGoods
--set g_Discount=0.75
--where g_Name='飞利浦 292'
--4)创建包含Goods表和Types表中指定信息的视图vw_TNameGoods (t_ID,t_Name,g_Name,g_Price,g_Discount)。
--create view vw_TNameGoods
--as
--select t1.t_ID,t_Name,g_Name,g_Price,g_Discount
--from Goods t1 join Types t2
--on t1.t_ID=t2.t_ID
--5)在视图vw_TNameGoods查询商品类别为“通信产品”,商品名称中包含"三星"
----select *
----from vw_TNameGoods
----where t_Name='通信产品' and g_Name like '%三星%'
--6)修改视图vw_HotGoods,删除其中的折扣列,并查看修改后的视图中的数据
--update vw_HotGoods
--set g_Discount=null
--(1)创建存储过程up_Orders,要求该存储过程返回所有订单的详细信息,
--create proc up_Orders
--as
--select o_ID 订单号 ,o_Date 订单日期 ,o_Sum 订单总额 ,c_Name 会员名称,e_Name 处理员工
--from Orders t1 join Customers t2
--on t1.c_ID=t2.c_ID
--inner join Employees t3
--on t1.e_ID=t3.e_ID
--(2)执行存储过程up_Orders,查询所有订单的详细信息。
--exec up_Orders
--(3)创建存储过程up_OrderByID,要求该存储过程能够根据输入的订单号返回订单详细信息,包括订单号、订单日期、订单总额、会员名称和处理员工。
--create proc up_OrderByID
--@o_ID char(14)
--as
--select o_ID 订单号 ,o_Date 订单日期 ,o_Sum 订单总额 ,c_Name 会员名称,e_Name 处理员工
--from Orders t1 join Customers t2
--on t1.c_ID=t2.c_ID
--inner join Employees t3
--on t1.e_ID=t3.e_ID
--where o_ID=@o_ID
--(4)执行存储过程up_OrderByID,查询订单号为“200708011012”订单详细信息
----exec up_OrderByID @o_ID='200708011012 '
--(7)创建存储过程up_Add,要求该存储过程能够实现对输入的两个数相加,并将结果输出。
--create proc up_Add
--(
--@num1 int,
--@num2 int,
--@total_num int output
--)
--as
--set @total_num=@num1+@num2
--(8)执行存储过程up_Add,计算78加上82的和。
--declare @total_num int
--exec up_Add 78 ,82 ,@total_num output
--print @total_num