视图和存储过程
视图
1、创建视图
create view student1(name,age,idd,aname) as select b.name,b.age,b.idd,a.name from student b,course a where b.idd=a.id
student1视图名
2、查看视图
select * from student1;
3、删除视图
drop view student1;
存储过程
1、创建存储过程
create procedure stud //stud 存储过程名
as
begin //开始
select * from student a left join course c on a.idd=c.id
end //结束
或者
CREATE PROCEDURE Get_Data
(
@Dealer_ID VARCHAR(50)
)
AS
SELECT * FROM myData WHERE Dealer_ID = @Dealer_ID
2、执行存储过程
exec stu 查看存储过程里面的信息
3、修改存储过程
ALTER PROCEDURE [dbo].[Get_Data]
(
@Dealer_ID VARCHAR(50),
@Period VARCHAR(20)
)
AS
SELECT * FROM myData WHERE Dealer_ID = @Dealer_ID AND Period = @Period
4、 删除存储过程
drop procedure stud