????1.??????δ洢????
????--1.??????δ洢????
????if (exists (select * from sys.objects where name = 'getAllBooks'))
????drop proc proc_get_student
????go
????create procedure getAllBooks
????as
????select * from books;
????--???????д洢????
????exec getAllBooks;
????2.???洢????
????alter procedure dbo.getAllBooks
????as
????select book_auth from books;
????3.????洢????
????drop procedure getAllBooks;
????4.???????洢????
????sp_rename getAllBooks??proc_get_allBooks;
????5.????????????洢????
?????洢????????????????????????????????
???????????????????洢??????????????java???????c?е???????
????????????????????洢??????λ?????????java??????????????
?????????????????????:
??????????????????????????????????????丳?????????????
?????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????
????(1)??????????洢????
????if (exists (select * from sys.objects where name = 'searchBooks'))
????drop proc searchBooks
????go
????create proc searchBooks(@bookID int)
????as
????--???book_id??????????????
????select * from books where book_id=@bookID;
????--???searchBooks
????exec searchBooks 1;
????(2)??2???????洢????
????if (exists (select * from sys.objects where name = 'searchBooks1'))
????drop proc searchBooks1
????go
????create proc searchBooks1(
????@bookID int??
????@bookAuth varchar(20)
????)
????as
????--???book_id??book_Auth??????????????
????select * from books where book_id=@bookID and book_auth=@bookAuth;
????exec searchBooks1 1??'???';
????(3)?????з??????洢????
????if (exists (select * from sys.objects where name = 'getBookId'))
????drop proc getBookId
????go
????create proc getBookId(
????@bookAuth varchar(20)??--???????????????
????@bookId int output --????/??????? ??????
????)
????as
????select @bookId=book_id from books where book_auth=@bookAuth
????--???getBookId????????????洢????
????declare @id int --?????????????????????д洢??????????
????exec getBookId '????'??@id output
????select @id as bookId;--as????????????????????
????(4)????????????洢????
????if (exists (select * from sys.objects where name = 'charBooks'))
????drop proc charBooks
????go
????create proc charBooks(
????@bookAuth varchar(20)='??%'??
????@bookName varchar(20)='%'
????)
????as
????select * from books where book_auth like @bookAuth and book_name like @bookName;
????--??д洢????charBooks
????exec charBooks '??%'??'??%';
????(5)????洢????
????with encryption???????????洢????????.??????????????????? sp_helptext ???洢??????????????????????????????? syscomments ???л??????ù???????.
????if (object_id('books_encryption'?? 'P') is not null)
????drop proc books_encryption
????go
????create proc books_encryption
????with encryption
????as
????select * from books;
????--??д????books_encryption
????exec books_encryption;
????exec sp_helptext 'books_encryption';--??????????"???? 'books_encryption' ???????????"