新聞中心
此文章主要介紹的是SQL Server存儲過程之入門學(xué)習(xí)導(dǎo)航, 如果你想創(chuàng)建SQL Server存儲過程的話,在操作之前你一定要先用use語句,對其聲明要將存儲過程存儲在哪個數(shù)據(jù)庫中.

創(chuàng)新互聯(lián)公司是專業(yè)的方正網(wǎng)站建設(shè)公司,方正接單;提供成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、外貿(mào)營銷網(wǎng)站建設(shè),網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行方正網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!
- e.g
- use company;
執(zhí)行之.之后就可以聲明SQL Server存儲過程了.
- e.g
- create procedure ***
- @id varchar(50) , @name int output
- as
- select @namename=name from table where id=@id
然后可以用alter對SQL Server存儲過程進(jìn)行修改.
declare可以聲明一個變量
用set對變量賦值
- e.g
- alter proc getempp
- @ID int
- as
- declare @Department int
- select @Department=a.Department
- from company.dbo.employee a
- inner join company.dbo.department b
- on a.Department=b.ID
- where a.ID=@ID
- if @@ROWCOUNT>0
- begin
- select *
- from company.dbo.department
- where ID=@Department
- select * from company.dbo.employee
- where Department=@Department
- end
- else
- begin
- RAISERROR('No record found',10,1)
- end
上例中的@Department是被選擇出來的值,然后用來為下面的if語句塊中的查詢服務(wù)的.
以上的相關(guān)內(nèi)容就是對SQL Server存儲過程入門學(xué)習(xí)的介紹,望你能有所收獲。
網(wǎng)站名稱:SQLServer存儲過程之入門學(xué)習(xí)導(dǎo)航
網(wǎng)址分享:http://m.5511xx.com/article/cogisds.html


咨詢
建站咨詢
