Stored Procedure, trigger, etc...., stored procedure trigger ..
Stored Procedure
If (object_id ('proc _ find_stu ', 'P') is not null)
Drop proc proc_find_stu
Go
Create proc proc_find_stu (@ startId int, @ endId int, @ outID int output)
As
Select * from Studentss where id between @ startId and @ endId
Set @ outID = (select COUNT (1) from Studentss where id between @ startId and @ endId)
Declare @ ss int = 0;
Exec proc_find_stu 1,6, @ ss out
Select @ ss
Trigger --- modify trigger
Create trigger class_stu
On goods
For update
As
Declare @ oldnumber int, @ newnumber int, @ id int;
Select @ oldnumber = number from deleted; -- old quantity
Select @ id = goodsid from deleted; -- id
Select @ newnumber = number from inserted; -- new quantity
Update cangku set number = @ oldnumber-(@ oldnumber-@ newnumber) where goodsid = @ id;
Drop trigger class_stu
Update goods set number = number-1 where goodsid = 1;
Select * from goods g inner join cangku c on g. goodsid = c. goodsid
View
Use Students
Select * from Studentss
-- Create a view
If (exists (select * from sys. objects where name = 'v _ stu '))
Drop view v_stu
Create view v_stu as select Id, StuName, StuClass, TeamName, Bishi, Jineng from Studentss;
Select * from v_stu
-- Modify View
Alter view v_stu as select id, name, sex from student;
Alter view v_stu (No., name, class, group name, test, and test) as select Id, StuName, StuClass, TeamName, Bishi, Jineng from Studentss
Select * from v_stu where class = '1510a ';
Select * from information_schema.views;