当前位置: 代码迷 >> SQL >> 小弟我的SQLSERVER 分页存储过程
  详细解决方案

小弟我的SQLSERVER 分页存储过程

热度:65   发布时间:2016-05-05 15:02:19.0
我的SQLSERVER 分页存储过程
/***  procedure name : kk_fenye*  author : michael*  此段代码是转载别人的。 *  create date : 2011-12-07*/create procedure kk_fenye---获得某一页的数据---@currPage int = 1,   --->当前页页码(即top currPage)@showColumn varchar(2000) = '*', --->需要查询的字段(即column1,column2,......)@tabName varchar(2000),   --->需要查看的表名(即from table_name)@strCondition varchar(2000) = '', --->查询条件(即where condition......) 不用加where关键字@ascColumn varchar(100) = '',  --->排序的字段名(即order by column asc/desc)@bitOrderType int = 0,   --->排序的类型(0为升序,1为降序)@pkColumn varchar(50) = '',  --->主键名称@pageSize int = 20   --->分页大小asbegin  --->存储过程开始---该存储过程需要用到的几个变量---declare @strTemp varchar(1000)declare @strSql varchar(4000)  --->该存储过程最后执行的语句declare @strOrderType varchar(1000) --->排序类型语句(order by column asc/desc)beginif @bitOrderType = 1  --->@bitOrderType = 1 即执行降序begin    set @strOrderType = ' order by ' + @ascColumn + ' desc'    set @strTemp = '<(select min'endelsebegin    set @strOrderType = ' order by ' + @ascColumn + ' asc'    set @strTemp = '>(select max'endif @currPage = 1 --->如果是第一页begin    if @strCondition != ''set @strSql = 'select top ' + str(@pageSize) + ' ' + @showColumn + ' from ' + @tabName + ' where ' + @strCondition + @strOrderType    elseset @strSql = 'select top ' + str(@pageSize) + ' ' + @showColumn + ' from ' + @tabName + @strOrderTypeendelse  --->其他页begin    if @strCondition != ''set @strSql = 'select top ' + str(@pageSize) + ' ' + @showColumn + ' from ' + @tabName + ' where ' + @strCondition + ' and ' +@pkColumn + @strTemp + '(' + @pkColumn + ')' + ' from (select top ' + str((@currPage-1)[email protected]) + ' ' + @pkColumn +' from ' + @tabName + @strOrderType + ') as TabTemp)' + @strOrderType    elseset @strSql = 'select top ' + str(@pageSize) + ' ' + @showColumn + ' from ' + @tabName + ' where ' + @pkColumn + @strTemp +'(' + @pkColumn + ')' + ' from (select top ' + str((@currPage-1)[email protected]) + ' ' + @pkColumn + ' from ' +@tabName + @strOrderType + ') as TabTemp)' + @strOrderTypeendendEXEC (@strSql)end --->存储过程结束go 


调用方法:
  exec kk_fenye 1,'*','accout1','','transactionDate',1,'id',25 

查询表TableName的所有字段的前25条记录,因为是第一页,排序字段为CreateDate,1表示降序排列主键是PkID。这个存储过程的功能比较强大,用在项目中
非常的适用。尤其是在百万级数据上,它的优势就显露无疑了。


 int pageNum = 1; int startdate = 20111011; int enddate = 20111013;sql="exec kk_fenye '"+pageNum+"','*','accout1','transactionDate >= "+startdate+"+and transactionDate <= "+enddate+"','transactionDate',1,'id',25";st = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,					ResultSet.CONCUR_UPDATABLE);rs=st.executeQuery("SET NOCOUNT ON;"+sql);


查询表记录数的存储过程
create procedure procRowsCount@tabName varchar(200),  --->需要查询的表名@colName varchar(200) = '*', --->需要查询的列名@condition varchar(200) = '' --->查询条件asbegin    declare @strSql varchar(255)    if @condition = ''set @strSql = 'select count(' + @colName + ') from ' + @tabName    elseset @strSql = 'select count(' + @colName + ') from ' + @tabName + ' where ' + @condition    EXEC (@strSql)end 


调用方法:
exec kk_procRowsCount 'accout1','transactionDate','transactionDate >= 20111011 and transactionDate <= 20111012'


通用存储过程之一:插入、更新、删除存储过程。
临时存储过程如下
CREATE PROC #AutoGeneration_IUD_P@TABLENAME VARCHAR(50),@FLAT  TINYINTASBEGIN DECLARE @HOST_NAME VARCHAR(200) DECLARE @GET_DATE DATETIME SELECT @HOST_NAME=HOST_NAME(),@GET_DATE=GETDATE() IF @FLAT=1 --插入 BEGIN DECLARE @INSERT_SQLROC NVARCHAR(4000) DECLARE @INSERT_SQL VARCHAR(8000) DECLARE @INSERT_PARAMETER VARCHAR(8000) DECLARE @INSERT_DESCRIPTION VARCHAR(8000) DECLARE @INSERT_REMARK VARCHAR(2000) DECLARE @INSERT_COLUMN VARCHAR(8000) SELECT @INSERT_SQLROC='',@INSERT_SQL='',@INSERT_PARAMETER='',@INSERT_DESCRIPTION='',   @INSERT_REMARK='',@INSERT_COLUMN='' SET @[email protected]_SQLROC+'IF EXISTS (SELECT 1 FROM SYSOBJECTS WHERE ID=OBJECT_ID([email protected]+'_AddNew'') AND XTYPE IN (N''P''))'+CHAR(10) SET @[email protected]_SQLROC+SPACE(5)+'DROP PROC [email protected]+'_AddNew'+CHAR(10) SET @[email protected]_SQLROC+'GO ' SELECT @[email protected]_PARAMETER+SPACE(4)+'@'+LTRIM(NAME)+SPACE(15-LEN(NAME))+     CASE WHEN xtype=34 THEN 'image'       WHEN xtype=35 THEN 'text'       WHEN xtype=36 THEN 'uniqueidentifier'       WHEN xtype=48 THEN 'tinyint'       WHEN xtype=52 THEN 'smallint'       WHEN xtype=56 THEN 'int'       WHEN xtype=58 THEN 'smalldatetime'       WHEN xtype=59 THEN 'real'       WHEN xtype=60 THEN 'money'       WHEN xtype=61 THEN 'datetime'       WHEN xtype=62 THEN 'float'       WHEN xtype=98 THEN 'sql_variant'       WHEN xtype=99 THEN 'ntext'       WHEN xtype=104 THEN 'bit'       WHEN xtype=106 THEN 'decimal'       WHEN xtype=108 THEN 'numeric'       WHEN xtype=122 THEN 'smallmoney'       WHEN xtype=127 THEN 'bigint'       WHEN xtype=165 THEN 'varbinary'          WHEN xtype=167 THEN 'varchar'+'('+LTRIM(length)+')'       WHEN xtype=173 THEN 'binary'       WHEN xtype=175 THEN 'char'+'('+LTRIM(length)+')'       WHEN xtype=189 THEN 'timestamp'       WHEN xtype=231 THEN 'nvarchar'+'('+LTRIM(length)+')'       WHEN xtype=239 THEN 'nchar'+'('+LTRIM(length)+')'       WHEN xtype=241 THEN 'xml'       WHEN xtype=231 THEN 'sysname' END+','+CHAR(10),   @[email protected]_REMARK+',@'+NAME,   @[email protected]_COLUMN+','+NAME FROM  (   SELECT NAME,CDEFAULT,A.ID,XTYPE,LENGTH,COLORDER  FROM SYSCOLUMNS A   WHERE A.ID=OBJECT_ID([email protected]+'')  AND COLUMNPROPERTY(A.ID,A.NAME,'IsIdentity')<>1   )TB ORDER BY COLORDER SET @[email protected]_DESCRIPTION+'/*+--------------------------------------+'+CHAR(10) SET @[email protected]_DESCRIPTION+'| 过程名称:[email protected]+'_AddNew'+CHAR(10) SET @[email protected]_DESCRIPTION+'| 功能说明:[email protected]+'的存储过程'+CHAR(10) SET @[email protected]_DESCRIPTION+'| 入口参数:'+STUFF(@INSERT_REMARK,1,1,'')+''+CHAR(10) SET @[email protected]_DESCRIPTION+'| 过程返回:无返回记录'+CHAR(10) SET @[email protected]_DESCRIPTION+'| 维护记录:Y/A'+CHAR(10) SET @[email protected]_DESCRIPTION+'| 使用案例:[email protected]+'_AddNew'+CHAR(10) SET @[email protected]_DESCRIPTION+'| 工作站名:[email protected]_NAME+''+CHAR(10) SET @[email protected]_DESCRIPTION+'| 联系方式:[email protected]'+CHAR(10) SET @[email protected]_DESCRIPTION+'| 创建日期:'+CONVERT(VARCHAR(20),@GET_DATE,120)+''+CHAR(10)  SET @[email protected]_DESCRIPTION+'+--------------------------------------+*/'+CHAR(10) SELECT @[email protected]_SQLROC+CHAR(10)[email protected]_DESCRIPTION+'CREATE PROC [email protected]+'_AddNew' SET @[email protected]_SQLROC+CHAR(13)+CHAR(10)+LEFT(@INSERT_PARAMETER,LEN(@INSERT_PARAMETER)-2)+CHAR(10) SET @[email protected]_SQLROC+'AS'+CHAR(10)+'BEGIN' SET @[email protected]_SQLROC+CHAR(10)+SPACE(4)+'SET NOCOUNT ON' SET @INSERT_SQL=SPACE(8)+'INSERT INTO [email protected]+'('+STUFF(@INSERT_COLUMN,1,1,'')+')'+CHAR(13)+CHAR(10)+SPACE(8)+' SELECT '+STUFF(@INSERT_REMARK,1,1,'') SET @[email protected]_SQLROC+CHAR(10)+CHAR(32)[email protected]_SQL SET @[email protected]_SQLROC+CHAR(10)+SPACE(8)+' SELECT _ROWCOUNT=@@ROWCOUNT' SET @[email protected]_SQLROC+CHAR(10)+SPACE(4)+'SET NOCOUNT OFF'  SET @[email protected]_SQLROC+CHAR(10)+'END' PRINT @INSERT_SQLROC+CHAR(10)+'GO ' --EXEC(@INSERT_SQLROC) --EXEC SP_EXECUTESQL @INSERT_SQLROC END IF @FLAT=2 --修改 BEGIN DECLARE @UPDATE_SQLROC VARCHAR(8000) DECLARE @UPDATE_SQL VARCHAR(8000)  DECLARE @UPDATE_PARAMETER VARCHAR(1000) DECLARE @UPDATE_DESCRIPTION VARCHAR(1000) DECLARE @UPDATE_REMARK VARCHAR(1000) DECLARE @UPDATE_KEY_COLUMN VARCHAR(1000) DECLARE @UPDATE_COLUMN VARCHAR(5000) SELECT  @UPDATE_SQLROC='',   @UPDATE_SQL='',@UPDATE_PARAMETER='',@UPDATE_DESCRIPTION='',   @UPDATE_REMARK='',@UPDATE_KEY_COLUMN='',@UPDATE_COLUMN='' SET @[email protected]_SQLROC+'IF EXISTS (SELECT 1 FROM SYSOBJECTS WHERE ID=OBJECT_ID([email protected]+'_Update'') AND XTYPE IN (N''P''))'+CHAR(10) SET @[email protected]_SQLROC+SPACE(5)+'DROP PROC [email protected]+'_Update'+CHAR(10) SET @[email protected]_SQLROC+' GO ' SELECT @[email protected]_PARAMETER+SPACE(4)+'@'+LTRIM(NAME)+SPACE(15-LEN(NAME))+     CASE WHEN xtype=34 THEN 'image'       WHEN xtype=35 THEN 'text'       WHEN xtype=36 THEN 'uniqueidentifier'       WHEN xtype=48 THEN 'tinyint'       WHEN xtype=52 THEN 'smallint'       WHEN xtype=56 THEN 'int'       WHEN xtype=58 THEN 'smalldatetime'       WHEN xtype=59 THEN 'real'       WHEN xtype=60 THEN 'money'       WHEN xtype=61 THEN 'datetime'       WHEN xtype=62 THEN 'float'       WHEN xtype=98 THEN 'sql_variant'       WHEN xtype=99 THEN 'ntext'       WHEN xtype=104 THEN 'bit'       WHEN xtype=106 THEN 'decimal'       WHEN xtype=108 THEN 'numeric'       WHEN xtype=122 THEN 'smallmoney'       WHEN xtype=127 THEN 'bigint'       WHEN xtype=165 THEN 'varbinary'          WHEN xtype=167 THEN 'varchar'+'('+LTRIM(length)+')'       WHEN xtype=173 THEN 'binary'       WHEN xtype=175 THEN 'char'+'('+LTRIM(length)+')'       WHEN xtype=189 THEN 'timestamp'       WHEN xtype=231 THEN 'nvarchar'+'('+LTRIM(length)+')'       WHEN xtype=239 THEN 'nchar'+'('+LTRIM(length)+')'       WHEN xtype=241 THEN 'xml'       WHEN xtype=231 THEN 'sysname' END+','+CHAR(10) FROM SYSCOLUMNS A    WHERE ID=OBJECT_ID([email protected]+'') SET NOCOUNT ON CREATE TABLE #(TABLE_QUALIFIER VARCHAR(100), TABLE_OWNER  VARCHAR(100), TABLE_NAME   VARCHAR(100), COLUMN_NAME  VARCHAR(100), KEY_SEQ      VARCHAR(50), PK_NAME   VARCHAR(100)) INSERT INTO # EXEC SP_PKEYS @TABLENAME SELECT @[email protected]_REMARK+','+COLUMN_NAME+'=@'+COLUMN_NAME FROM # SELECT @[email protected]_KEY_COLUMN+','+NAME+'=@'+NAME FROM SYSCOLUMNS A    WHERE ID=OBJECT_ID([email protected]+'') AND NAME NOT IN (SELECT COLUMN_NAME FROM #) DROP TABLE # SET NOCOUNT OFF  IF DATALENGTH(@UPDATE_PARAMETER)>0  BEGIN   SET @UPDATE_PARAMETER=LEFT(@UPDATE_PARAMETER,LEN(@UPDATE_PARAMETER)-2)   SET @[email protected]_DESCRIPTION+'/*+--------------------------------------+'+CHAR(10)   SET @[email protected]_DESCRIPTION+'| 过程名称:[email protected]+'_Update'+CHAR(10)   SET @[email protected]_DESCRIPTION+'| 功能说明:[email protected]+'的存储过程'+CHAR(10)   SET @[email protected]_DESCRIPTION+'| 入口参数:'+STUFF(@UPDATE_REMARK,1,1,'')+''+CHAR(10)   SET @[email protected]_DESCRIPTION+'| 过程返回:无返回记录'+CHAR(10)   SET @[email protected]_DESCRIPTION+'| 维护记录:Y/A'+CHAR(10)   SET @[email protected]_DESCRIPTION+'| 使用案例:[email protected]+'_Update'+CHAR(10)   SET @[email protected]_DESCRIPTION+'| 工作站名:[email protected]_NAME+''+CHAR(10)   SET @[email protected]_DESCRIPTION+'| 联系方式:[email protected]'+CHAR(10)   SET @[email protected]_DESCRIPTION+'| 创建日期:'+CONVERT(VARCHAR(20),@GET_DATE,120)+''+CHAR(10)    SET @[email protected]_DESCRIPTION+'+--------------------------------------+*/'+CHAR(10)   SELECT @[email protected]_SQLROC+CHAR(10)[email protected]_DESCRIPTION+'CREATE PROC [email protected]+'_Update'   SET @[email protected]_SQLROC+CHAR(13)+CHAR(10)[email protected]_PARAMETER+CHAR(10)   SET @[email protected]_SQLROC+'AS'+CHAR(10)+'BEGIN'   SET @[email protected]_SQLROC+CHAR(10)+SPACE(4)+'SET NOCOUNT ON'+CHAR(10)   SET @UPDATE_SQL=SPACE(8)+'UPDATE [email protected]+CHAR(10)+SPACE(8)+'SET '   SET @[email protected][email protected]_SQL+STUFF(@UPDATE_KEY_COLUMN,1,1,'')   SET @[email protected]_SQLROC+CHAR(10)+SPACE(8)+'FROM [email protected]+CHAR(10)+SPACE(8)+'WHERE '+STUFF(@UPDATE_REMARK,1,1,'')+''   SET @[email protected]_SQLROC+CHAR(10)+SPACE(8)+'SELECT _ROWCOUNT=@@ROWCOUNT'   SET @[email protected]_SQLROC+CHAR(10)+SPACE(4)+'SET NOCOUNT OFF'   SET @[email protected]_SQLROC+CHAR(10)+'END'    PRINT @UPDATE_SQLROC+CHAR(13)+CHAR(10)+'GO'   --EXECUTE(@UPDATE_SQLROC+' GO ')  END END IF @FLAT=3 --删除 BEGIN DECLARE @DELETE_SQLROC VARCHAR(8000) DECLARE @DELETE_SQL VARCHAR(8000)  DECLARE @DELETE_PARAMETER VARCHAR(1000) DECLARE @DELETE_DESCRIPTION VARCHAR(1000) DECLARE @DELETE_REMARK VARCHAR(1000) DECLARE @DELETE_KEY_COLUMN VARCHAR(1000) SELECT  @DELETE_SQLROC='',@DELETE_SQL='',@DELETE_PARAMETER='',@DELETE_DESCRIPTION='',   @DELETE_REMARK='',@DELETE_KEY_COLUMN='' SET  @[email protected]_SQLROC+'IF EXISTS (SELECT 1 FROM SYSOBJECTS WHERE ID=OBJECT_ID([email protected]+'_Remove'') AND XTYPE IN (N''P''))'+CHAR(10) SET  @[email protected]_SQLROC+SPACE(5)+'DROP PROC [email protected]+'_Remove'+CHAR(10) SET  @[email protected]_SQLROC+' GO ' SET NOCOUNT ON CREATE TABLE #_#(TABLE_QUALIFIER VARCHAR(100), TABLE_OWNER  VARCHAR(100), TABLE_NAME   VARCHAR(100), COLUMN_NAME  VARCHAR(100), KEY_SEQ      VARCHAR(50), PK_NAME   VARCHAR(100)) INSERT INTO #_# EXEC SP_PKEYS @TABLENAME SELECT @[email protected]_KEY_COLUMN+','+COLUMN_NAME+'=@'+COLUMN_NAME,   @[email protected]_REMARK+',@'+COLUMN_NAME FROM #_# SELECT @[email protected]_PARAMETER+SPACE(4)+'@'+LTRIM(NAME)+SPACE(15-LEN(NAME))+     CASE WHEN xtype=34 THEN 'image'       WHEN xtype=35 THEN 'text'       WHEN xtype=36 THEN 'uniqueidentifier'       WHEN xtype=48 THEN 'tinyint'       WHEN xtype=52 THEN 'smallint'       WHEN xtype=56 THEN 'int'       WHEN xtype=58 THEN 'smalldatetime'       WHEN xtype=59 THEN 'real'       WHEN xtype=60 THEN 'money'       WHEN xtype=61 THEN 'datetime'       WHEN xtype=62 THEN 'float'       WHEN xtype=98 THEN 'sql_variant'       WHEN xtype=99 THEN 'ntext'       WHEN xtype=104 THEN 'bit'       WHEN xtype=106 THEN 'decimal'       WHEN xtype=108 THEN 'numeric'       WHEN xtype=122 THEN 'smallmoney'       WHEN xtype=127 THEN 'bigint'       WHEN xtype=165 THEN 'varbinary'          WHEN xtype=167 THEN 'varchar'+'('+LTRIM(length)+')'       WHEN xtype=173 THEN 'binary'       WHEN xtype=175 THEN 'char'+'('+LTRIM(length)+')'       WHEN xtype=189 THEN 'timestamp'       WHEN xtype=231 THEN 'nvarchar'+'('+LTRIM(length)+')'       WHEN xtype=239 THEN 'nchar'+'('+LTRIM(length)+')'       WHEN xtype=241 THEN 'xml'       WHEN xtype=231 THEN 'sysname' END+','+CHAR(10) FROM SYSCOLUMNS A    WHERE ID=OBJECT_ID([email protected]+'')  AND NAME IN (SELECT COLUMN_NAME FROM #_#) DROP TABLE #_# SET NOCOUNT OFF  IF DATALENGTH(@DELETE_PARAMETER)>0  BEGIN   SET @DELETE_PARAMETER=LEFT(@DELETE_PARAMETER,LEN(@DELETE_PARAMETER)-2)   SET @[email protected]_DESCRIPTION+'/*+--------------------------------------+'+CHAR(10)   SET @[email protected]_DESCRIPTION+'| 过程名称:[email protected]+'_Remove'+CHAR(10)   SET @[email protected]_DESCRIPTION+'| 功能说明:[email protected]+'的存储过程'+CHAR(10)   SET @[email protected]_DESCRIPTION+'| 入口参数:'+STUFF(@DELETE_REMARK,1,1,'')+''+CHAR(10)   SET @[email protected]_DESCRIPTION+'| 过程返回:无返回记录'+CHAR(10)   SET @[email protected]_DESCRIPTION+'| 维护记录:Y/A'+CHAR(10)   SET @[email protected]_DESCRIPTION+'| 使用案例:[email protected]+'_Remove'+CHAR(10)   SET @[email protected]_DESCRIPTION+'| 工作站名:'+@HOST_NAME+''+CHAR(10)   SET @DELETE_DESCRIPTION=@DELETE_DESCRIPTION+'| 联系方式:ZLP321001@HOTMAIL.COM'+CHAR(10)   SET @DELETE_DESCRIPTION=@DELETE_DESCRIPTION+'| 创建日期:'+CONVERT(VARCHAR(20),@GET_DATE,120)+''+CHAR(10)    SET @DELETE_DESCRIPTION=@DELETE_DESCRIPTION+'+--------------------------------------+*/'+CHAR(10)   SELECT @DELETE_SQLROC=@DELETE_SQLROC+CHAR(10)+@DELETE_DESCRIPTION+'CREATE PROC SP_'+@TABLENAME+'_Remove'   SET @DELETE_SQLROC=@DELETE_SQLROC+CHAR(13)+CHAR(10)+@DELETE_PARAMETER+CHAR(10)   SET @DELETE_SQLROC=@DELETE_SQLROC+'AS'+CHAR(10)+'BEGIN'   SET @DELETE_SQLROC=@DELETE_SQLROC+CHAR(10)+SPACE(4)+'SET NOCOUNT ON'   SET @DELETE_SQL='DELETE '+@TABLENAME+CHAR(10)+SPACE(8)+'WHERE '   SET @DELETE_SQLROC=@DELETE_SQLROC+CHAR(10)+SPACE(8)+@DELETE_SQL+STUFF(@DELETE_KEY_COLUMN,1,1,'')   SET @DELETE_SQLROC=@DELETE_SQLROC+CHAR(10)+SPACE(8)+'SELECT _ROWCOUNT=@@ROWCOUNT'   SET @DELETE_SQLROC=@DELETE_SQLROC+CHAR(10)+SPACE(4)+'SET NOCOUNT OFF'   SET @DELETE_SQLROC=@DELETE_SQLROC+CHAR(10)+'END'    PRINT @DELETE_SQLROC+CHAR(13)+CHAR(10)+'GO'     --EXECUTE(@DELETE_SQLROC+' GO ')   END ENDENDGO


CREATE PROC #SP_Generation_IUD@TABLENAMES VARCHAR(8000)ASBEGINDECLARE @I INTDECLARE @TABLENAME VARCHAR(100)SET @I=CHARINDEX(',',@TABLENAMES)WHILE @I>0BEGIN SET @TABLENAME=LEFT(@TABLENAMES,@I-1) EXEC #AutoGeneration_IUD_P @TABLENAME,1 EXEC #AutoGeneration_IUD_P @TABLENAME,2 EXEC #AutoGeneration_IUD_P @TABLENAME,3 SET @TABLENAMES=RIGHT(@TABLENAMES,LEN(@TABLENAMES)-@I) SET @I=CHARINDEX(',',@TABLENAMES)ENDIF LEN(@TABLENAMES)>0BEGIN EXEC #AutoGeneration_IUD_P @TABLENAMES,1 EXEC #AutoGeneration_IUD_P @TABLENAMES,2 EXEC #AutoGeneration_IUD_P @TABLENAMES,3ENDENDGO


--调用方法如下: exec  #SP_Generation_IUD '表1,表2,表3'

--Example:

exec  #SP_Generation_IUD 'ICR_PermittedUrl,ICR_ForbiddenUrl'GODROP PROC  #SP_Generation_IUDGODROP PROC #AutoGeneration_IUD_PGO

删除表ICR_ForbiddenUrl的存储过程
/*+--------------------------------------+| 过程名称:SP_ICR_ForbiddenUrl_Remove| 功能说明:删除表ICR_ForbiddenUrl的存储过程| 入口参数:@ID| 过程返回:无返回记录| 维护记录:Y/A| 使用案例:SP_ICR_ForbiddenUrl_Remove| 工作站名:XXX| 联系方式:kk@HOTMAIL.COM| 创建日期:2010-07-12 19:18:39+--------------------------------------+*/CREATE PROC SP_ICR_ForbiddenUrl_Remove    @ID             intASBEGIN    SET NOCOUNT ON        DELETE ICR_ForbiddenUrl        WHERE ID=@ID        SELECT _ROWCOUNT=@@ROWCOUNT    SET NOCOUNT OFFENDGO



更新表ICR_ForbiddenUrl的存储过程
/*+--------------------------------------+| 过程名称:SP_ICR_ForbiddenUrl_Update| 功能说明:更新表ICR_ForbiddenUrl的存储过程| 入口参数:ID=@ID| 过程返回:无返回记录| 维护记录:Y/A| 使用案例:SP_ICR_ForbiddenUrl_Update| 工作站名:XXX| 联系方式:kk@HOTMAIL.COM| 创建日期:2010-07-12 09:18:39+--------------------------------------+*/CREATE PROC SP_ICR_ForbiddenUrl_Update    @ID             int,    @URL            varchar(100),    @State          tinyint,    @CategoryID     int,    @Name           varchar(50),    @Description    varchar(200),    @DateCreated    datetimeASBEGIN    SET NOCOUNT ON        UPDATE ICR_ForbiddenUrl        SET URL=@URL,State=@State,CategoryID=@CategoryID,Name=@Name,Description=@Description,DateCreated=@DateCreated        FROM ICR_ForbiddenUrl        WHERE ID=@ID        SELECT _ROWCOUNT=@@ROWCOUNT    SET NOCOUNT OFFENDGOIF EXISTS (SELECT 1 FROM SYSOBJECTS WHERE ID=OBJECT_ID('SP_ICR_ForbiddenUrl_Remove') AND XTYPE IN (N'P'))     DROP PROC SP_ICR_ForbiddenUrl_Remove GO 


插入表ICR_ForbiddenUrl的存储过程
/*+--------------------------------------+| 过程名称:SP_ICR_ForbiddenUrl_Remove| 功能说明:删除表ICR_ForbiddenUrl的存储过程| 入口参数:@ID| 过程返回:无返回记录| 维护记录:Y/A| 使用案例:SP_ICR_ForbiddenUrl_Remove| 工作站名:XXX| 联系方式:kk@HOTMAIL.COM| 创建日期:2010-07-12 19:18:39+--------------------------------------+*/CREATE PROC SP_ICR_ForbiddenUrl_AddNew    @ID             int,    @URL            varchar(100),    @State          tinyint,    @CategoryID     int,    @Name           varchar(50),    @Description    varchar(200),    @DateCreated    datetimeASBEGIN    SET NOCOUNT ON         INSERT INTO ICR_ForbiddenUrl(ID,URL,State,CategoryID,Name,Description,DateCreated)         SELECT @ID,@URL,@State,@CategoryID,@Name,@Description,@DateCreated         SELECT _ROWCOUNT=@@ROWCOUNT    SET NOCOUNT OFFENDGO IF EXISTS (SELECT 1 FROM SYSOBJECTS WHERE ID=OBJECT_ID('SP_ICR_ForbiddenUrl_Update') AND XTYPE IN (N'P'))     DROP PROC SP_ICR_ForbiddenUrl_Update GO 

  相关解决方案