sql server 聯機叢書中的定義:
  存儲過程是保存起來的可以接受和返回用戶提供的參數的 transact-sql 語句的集合。
  可以創建一個過程供永久使用,或在一個會話中臨時使用(局部臨時過程),或在所有會話中臨時使用(全局臨時過程)。
  也可以創建在 microsoft sql server 啟動時自動運行的存儲過程。
create proc 存儲過程名稱
    [參數列表(多個以“,”分隔)]
as
sql 語句
create proc upgetusername
@intuserid        int,
@ostrusername nvarchar(20) output                -- 要輸出的參數
as
begin
        -- 將uname的值賦給 @ostrusername 變量,即要輸出的參數
        select @ostrusername=uname from uuser where [email protected]
end
dim adocomm
'// 創建一個對象,我們用來調用存儲過程
set adocomm = createobject("adodb.command")
with adocomm
        '// 設置連接,設 adoconn 為已經連接的 adodb.connection 對象
        .activeconnection = adoconn
        '// 類型為存儲過程,adcmdstoredproc = 4
        .commandtype = 4
        '// 存儲過程名稱
        .commandtext = "upgetusername"
        '// 設置用戶編號
        .parameters.item("@intuserid").value = 1
        '// 執行存儲過程
        .execute
        
        '// 取得從存儲過程返回的用戶名稱
        response.write "用戶名:" & .parameters.item("@ostrusername").value
end with
'// 釋放對象
set adocomm = nothing
create proc upuserlogin
@strloginname        nvarchar(20),
@strloginpwd        nvarchar(20),
@blnreturn                bit output
as
-- 定義一個臨時用來保存密碼的變量
declare @strpwd nvarchar(20)
begin
        -- 從表中查詢當前用戶的密碼,賦值給 @strpwd 變量,下面要對他進行比較
        select @strpwd=uloginpwd from uuser where [email protected]
        if @strloginpwd = @strpwd
                begin
                        set @blnreturn = 1
                        -- 更新用戶最后登錄時間
                        update uuser set ulastlogin=getdate() where [email protected]
                end
        else
                set @blnreturn = 0
end
dim adocomm
'// 創建一個對象,我們用來調用存儲過程
set adocomm = createobject("adodb.command")
with adocomm
        '// 設置連接,設 adoconn 為已經連接的 adodb.connection 對象
        .activeconnection = adoconn
        '// 類型為存儲過程,adcmdstoredproc = 4
        .commandtype = 4
        '// 存儲過程名稱
        .commandtext = "upuserlogin"
        '// 設置登錄名稱
        .parameters.item("@strloginname").value = "admin"
        '// 設置登錄密碼
        .parameters.item("@strloginpwd").value = "123456"
        '// 執行存儲過程
        .execute
        
        '// 判斷是否登錄成功
        if .parameters.item("@blnreturn").value = 1 then
                response.write "恭喜你,登錄成功!"
        else
                response.write "不是吧,好像錯了哦。。。"
        end if
end with
'// 釋放對象
set adocomm = nothing
create proc upgetuserinfos
@intusergroup        int
as
begin
        -- 從數據庫中抽取符合條件的數據
        select uname,ugroup,ulastlogin from uuser where [email protected]
        -- 插入一列合計
        union
        select '合計人數:',count(ugroup),null from uuser where [email protected]
end
dim adocomm
dim adort
'// 創建一個對象,我們用來調用存儲過程
set adocomm = createobject("adodb.command")
set adors = createobject("adodb.recordset")
with adocomm
        '// 設置連接,設 adoconn 為已經連接的 adodb.connection 對象
        .activeconnection = adoconn
        '// 類型為存儲過程,adcmdstoredproc = 4
        .commandtype = 4
        '// 存儲過程名稱
        .commandtext = "upgetuserinfos"
        '// 設置用戶組
        .parameters.item("@intusergroup").value = 1
        '// 執行存儲過程,和以上幾個例子不同,這里使用recordset的open方法
        adors.open adocomm
        '// 顯示第一個值
        response.write adors.fields(0).value
end with
'// 釋放對象
set adors = nothing
set adocomm = nothing