sql查詢分析器裡建立乙個帶有輸出的儲存過程
if(exists(select * from sysobjects where name='sel' and xtype='p'))
drop proc sel
gocreate proc sel
@cou int output
asbegin
select @cou=count(*) from web_news
endsql查詢分析器裡執行帶有輸出引數的儲存過程
declare @cou int
exec sel @cou output
select @cou
建立帶有輸入引數的儲存過程
if(exists(select * from sysobjects where name='checkuser' and xtype='p'))
drop proc checkuser
gocreate proc checkuser
@username nchar(20)
asbegin
select * from web_news where username=@username
end執行這個帶有輸入引數的儲存過程
exec checkuser aa
帶有輸入和輸出引數的儲存過程
if exists(select * from sysobjects where name='checkuser' and xtype='p')
drop proc checkuser
gocreate proc checkuser
@username nchar(20),
@result int output
asselect @result=count(*) from web_news where username=@username
執行帶有輸入和輸出引數的儲存過程
declare @result int
exec checkuser "a",@result output
select @result
簡單儲存過程語句
if exists select from dbo.sysobjects whereid object id n dbo pro relateproselect andobjectproperty id n isprocedure 1 drop procedure dbo pro relatepro...
SQL分頁語句及簡單的SQL分頁儲存過程
假分頁 從資料庫中選擇所有的記錄後再進行分頁 真分頁 只從資料庫中選擇當前頁的記錄 sql select top每頁顯示的記錄數 fromtopicwhereid not in select top 當前的頁數 1 每頁顯示的記錄數 idfromtopicorder byiddesc order b...
分頁SQL語句 儲存過程
分頁儲存過程一 alter procedure dbo fy startrowindex int,maximumrows int asbegin select from select ugid,uname,row number over order by ugid desc rownum from ...