儲存過程返回記錄總數

2021-04-12 15:18:26 字數 519 閱讀 7166

在網上找了很長時間,經過個人總結,終於得到如願的**:

create procedure recordcount

(@tablename nvarchar(100),

@strwhere nvarchar(500)='')as

declare @flag int

declare @sqlstr nvarchar(1000)

set @flag = 0

if @strwhere != ''

set @sqlstr = 'select count(id) from ' + @tablename + ' where ' + @strwhere

else

set @sqlstr = 'select count(id) from ' + @tablename

exec sp_executesql   @sqlstr,n'@count   int  output',@flag     output

go雖然還不知道最後一句是什麼意思,呵呵,先用了再說 

儲存過程返回記錄集總數,及輸出。

在查詢分析器中執行建立儲存過程 create procedure recordcount strwhere nvarchar 500 count int output as declare sqlstr nvarchar 1000 if strwhere set sqlstr n select co...

Oracle分頁的儲存過程 返回頁總數

create or replace package autopagenation is author mark created 2010 12 30 11 23 18 purpose public type declarations 返回結果集的游標 type typecousor is ref c...

Oracle儲存過程返回記錄集

oracle的儲存過程返回記錄集,關鍵之處是要用游標。關於資料庫的游標 cursor 大家肯定都接觸不少,我們可以通過open,fetch,close操作控制游標進行各種方便的操作,這方面的例子我就不在重複了。我們現在要介紹的是游標變數 cursor variable 類似游標,游標變數也是指向乙個...