MSSQL中提供的功能,可供使用者撰寫預存程序(Stored Procedure)
預存程序,簡單的來說就是你寫好了一段(連串)SQL語法,存在資料庫中,
之後可以透過呼叫執行(EXEC 預存程序名稱),去執行已寫好的語法。
寫法如下:
- 新增預存程序使用 Create
- 新增預存程序使用 Alter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*-------------------------------------------------- | |
description:取得Studen資料 | |
author:Kyle | |
date:2018/5/31 | |
testing Code: | |
-------------------------------------------------- | |
exec MyStudent_GetList | |
@Student_Name='KYLE' | |
-------------------------------------------------- | |
drop Procedure MyStudent_GetList | |
--------------------------------------------------*/ | |
Create Procedure [dbo].[MyStudent_GetList] | |
@Student_Name nvarchar(100) =null | |
AS | |
BEGIN | |
Select * from MyStuden | |
Where Student_Name=@Student_Name | |
END |
沒有留言:
張貼留言