SQL ¸ßЧͨÓ÷ÖÒ³´æ´¢¹ý³Ì(Ë«Ïò¼ìË÷)
create PROC [dbo].[P_viewPage_A]
/*
¸ßЧͨÓ÷ÖÒ³´æ´¢¹ý³Ì(Ë«Ïò¼ìË÷)
¾´¸æ£ºÊÊÓÃÓÚµ¥Ò»Ö÷¼ü»ò´æÔÚΨһֵÁеıí»òÊÓͼ
ps:SqlÓï¾äΪ8000×Ö½Ú,µ÷ÓÃʱÇë×¢Òâ´«Èë²ÎÊý¼°sql×ܳ¤¶È²»Òª³¬¹ýÖ¸¶¨·¶Î§
*/
@TableName VARCHAR(200), --±íÃû
@FieldList VARCHAR(2000), --ÏÔʾÁÐÃû£¬Èç¹ûÊÇÈ«²¿×Ö¶ÎÔòΪ*
@PrimaryKey VARCHAR(100), --µ¥Ò»Ö÷¼ü»òΨһֵ¼ü
@Where VARCHAR(2000), --²éѯÌõ¼þ ²»º¬'where'×Ö·û£¬Èçid>10 and len(userid)>9
@Order VARCHAR(1000), --ÅÅÐò ²»º¬'order by'×Ö·û£¬Èçid asc,userid desc£¬±ØÐëÖ¸¶¨asc»òdesc
--×¢Òâµ±@SortType=3ʱÉúЧ£¬¼Çסһ¶¨ÒªÔÚ×îºó¼ÓÉÏÖ÷¼ü£¬·ñÔò»áÈÃÄã±È½ÏÓôÃÆ
@SortType INT, --ÅÅÐò¹æÔò 1:ÕýÐòasc 2:µ¹Ðòdesc 3:¶àÁÐÅÅÐò·½·¨
@RecorderCount INT, --¼Ç¼×ÜÊý 0:»á·µ»Ø×ܼǼ
@PageSize INT, --ÿҳÊä³öµÄ¼Ç¼Êý
@PageIndex INT, --µ±Ç°Ò³Êý
@TotalCount INT OUTPUT, --¼Ç·µ»Ø×ܼǼ
@TotalPageCount INT OUTPUT --·µ»Ø×ÜÒ³Êý
AS
SET NOCOUNT ON
IF ISNULL(@TotalCount,'') = '' SET @TotalCount = 0
SET @Order = RTRIM(LTRIM(@Order))
SET @PrimaryKey = RTRIM(LTRIM(@PrimaryKey))
SET @FieldList = REPLACE(RTRIM(LTRIM(@FieldList)),' ','')
WHILE CHARINDEX(', ',@Order) > 0 OR CHARINDEX(' ,',@Order) > 0
BEGIN
SET @Order = REPLACE(@Order,', ',',')
SET @Order = REPLACE(@Order,' ,',',')
END
IF ISNULL(@TableName,'') = '' OR ISNULL(@FieldList,'') = ''
OR ISNULL(@PrimaryKey,'') = ''
OR @SortType < 1 OR @SortType >3
OR @RecorderCount < 0 OR @PageSize < 0 OR @PageIndex < 0
BEGIN
PRINT('ERR_00')
RETURN
END
IF @SortType = 3
BEGIN
IF (UPPER(RIGHT(@Order,4))!=' ASC' AND UPPER(
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
CREATE PROCEDURE fenye
@tblName varchar(255)='wdf1', -- ±íÃû
@strGetFields varchar(1000) = '*', -- ÐèÒª·µ»ØµÄÁÐ
@fldName varchar(255)='userid', -- ÅÅÐòµÄ×Ö¶ÎÃû
@PageSize int = 10, -- Ò³³ß´ç
@PageIndex int = 1, -- Ò³Âë
@doCount bit = 0, -- ·µ»Ø¼Ç¼×ÜÊý, ·Ç 0 ÖµÔò·µ»Ø
@OrderType bit = 0, -- Éè ......
º¯ÊýÊÇÒ»ÖÖÓÐÁã¸ö»ò¶à¸ö²ÎÊý²¢ÇÒÓÐÒ»¸ö·µ»ØÖµµÄ³ÌÐò¡£ÔÚSQLÖÐOracleÄÚ½¨ÁËһϵÁк¯Êý£¬ÕâЩº¯Êý¶¼¿É±»³ÆΪSQL»òPL/SQLÓï¾ä£¬º¯ÊýÖ÷Òª·ÖΪÁ½´óÀࣺ
µ¥Ðк¯Êý¡¢×麯Êý
±¾ÎĽ«ÌÖÂÛÈçºÎÀûÓõ¥Ðк¯ÊýÒÔ¼°Ê¹ÓùæÔò¡£
SQLÖеĵ¥Ðк¯Êý
SQLºÍPL/SQLÖÐ×Ô´øºÜ¶àÀàÐ͵ĺ¯Êý£¬ÓÐ×Ö·û¡¢Êý×Ö¡¢ÈÕÆÚ¡¢×ª»»¡¢ºÍ»ìºÏÐ͵ȶàÖÖº¯ ......
SELECT EMP_ID,EMP_NO,LOGIN_NAME,EMP_NAME,SITE_CODE,DEPT_CODE,
JOB_DESC,HRMS_DEPT_CODE,MAIL_ACCOUNT,EXT_NO ,
(case when SITE_CODE='QCS' then 1 else 2 end) site
from dbo.AM_EMPLOYEE
WHERE ACTIVE = 'Y' AND EXT_NO = '6006'
order by site
ÏëÒªÔÚÔ±¹¤±íÖвé³öµç»°ºÅΪ6006µÄÔ±¹¤µÄÓ¢ÎÄÃûÀ´×÷ΪϵͳҳÃæÉ ......