SqlServer´æ´¢¹ý³Ì·ÖÒ³
--TOP n ʵÏÖµÄͨÓ÷ÖÒ³´æ´¢¹ý³Ì(ת×Ô×Þ½¨)
CREATE PROC sp_PageView
@tbname sysname, --Òª·ÖÒ³ÏÔʾµÄ±íÃû
@FieldKey nvarchar(1000), --ÓÃÓÚ¶¨Î»¼Ç¼µÄÖ÷¼ü(Ωһ¼ü)×Ö¶Î,¿ÉÒÔÊǶººÅ·Ö¸ôµÄ¶à¸ö×Ö¶Î
@PageCurrent int=1, --ÒªÏÔʾµÄÒ³Âë
@PageSize int=10, --ÿҳµÄ´óС(¼Ç¼Êý)
@FieldShow nvarchar(1000)='', --ÒÔ¶ººÅ·Ö¸ôµÄÒªÏÔʾµÄ×Ö¶ÎÁбí,Èç¹û²»Ö¸¶¨,ÔòÏÔʾËùÓÐ×Ö¶Î
@FieldOrder nvarchar(1000)='', --ÒÔ¶ººÅ·Ö¸ôµÄÅÅÐò×Ö¶ÎÁбí,¿ÉÒÔÖ¸¶¨ÔÚ×ֶκóÃæÖ¸¶¨DESC/ASC
ÓÃÓÚÖ¸¶¨ÅÅÐò˳Ðò
@Where nvarchar(1000)='', --²éѯÌõ¼þ
@PageCount int OUTPUT --×ÜÒ³Êý
AS
SET NOCOUNT ON
--¼ì²é¶ÔÏóÊÇ·ñÓÐЧ
IF OBJECT_ID(@tbname) IS NULL
BEGIN
RAISERROR(N'¶ÔÏó"%s"²»´æÔÚ',1,16,@tbname)
RETURN
END
IF OBJECTPROPERTY(OBJECT_ID(@tbname),N'IsTable')=0
AND OBJECTPROPERTY(OBJECT_ID(@tbname),N'IsView')=0
AND OBJECTPROPERTY(OBJECT_ID(@tbname),N'IsTableFunction')=0
BEGIN
RAISERROR(N'"%s"²»ÊÇ±í¡¢ÊÓͼ»òÕß±íÖµº¯Êý',1,16,@tbname)
RETURN
END
--·ÖÒ³×ֶμì²é
IF ISNULL(@FieldKey,N'')=''
BEGIN
RAISERROR(N'·ÖÒ³´¦ÀíÐèÒªÖ÷¼ü£¨»òÕßΩһ¼ü£©',1,16)
RETURN
END
--ÆäËû²ÎÊý¼ì²é¼°¹æ·¶
IF ISNULL(@PageCurrent,0)<1 SET @PageCurrent=1
IF ISNULL(@PageSize,0)<1 SET @PageSize=10
IF ISNULL(@FieldShow,N'')=N'' SET @FieldShow=N'*'
IF ISNULL(@FieldOrder,N'')=N''
SET @FieldOrder=N''
ELSE
SET @FieldOrder=N'ORDER BY '+LTRIM(@FieldOrder)
IF ISNULL(@Where,N'')=N''
SET @Where=N''
ELSE
SET @Where=N'WHERE ('+@Where+N')'
--Èç¹û@PageCountΪNULLÖµ,Ôò¼ÆËã×ÜÒ³Êý(ÕâÑùÉè¼Æ¿ÉÒÔÖ»ÔÚµÚÒ»´Î¼ÆËã×ÜÒ³Êý,ÒÔºóµ÷ÓÃʱ,°Ñ×ÜÒ³Êý´«»Ø¸ø´æ´¢¹ý³Ì,±ÜÃâÔٴμÆËã×ÜÒ³Êý,¶ÔÓÚ²»Ïë¼ÆËã×ÜÒ³ÊýµÄ´¦Àí¶øÑÔ,¿ÉÒÔ¸ø@PageCount¸³Öµ)
IF @PageCount IS NULL
BEGIN
DECLARE @sql nvarchar(4000)
SET @sql=N'SELECT @PageCount=COUNT(*)'
+N' from '+@tbname
+N' '+@Where
EXEC sp_executesql @sql,N'@PageCount int OUTPUT',@PageCount OUTPUT
SET @PageCo
Ïà¹ØÎĵµ£º
Oracle´æ´¢¹ý³Ìת³ÉSqlserver´æ´¢¹ý³Ì
1.ÈÕÆÚת»»
Oracle£º TO_NUMBER(TO_CHAR(SYSDATE, 'YYYYMMDD'))
SqlServer£ºCAST(CONVERT(CHAR(8),GETDATE(), 112) AS INT)
×¢£ºÆäÖБYYYYMMDD’¸ñʽ ¶ÔÓ¦112
2.ROWIDת»»
Oracle£º ROWID
SqlServer: PRIMARY KEY(±íÖ÷¼ü)
3.ROWNUM ......
1.°²×°ºÃSQLServer 2005Êý¾Ý¿âÈí¼þ£¬½Ó×Å×îÖØÒªµÄ¾ÍÊÇ°²×°Êý¾Ý¿âÇý¶¯SQL Server 2005 driver for JDBC£¬¿ÉÒÔµ½:http://download.microsoft.com/download/8/B/D/8BDABAE2-B6EA-41D4-B903-7916EF3690EF/sqljdbc_1.2.2323.101_enu.exeÏÂÔØ
2.½«JDBC½âѹµ½ÈÎÒâµÄλÖã¬ÔÚ°²×°Ä¿Â¼ÀïÕÒµ½sqljdbc.jarÎļþ£¬ÒÔÇ°µÄÎÄÕÂÖÐÒѾ½²¹ ......
select a.UserName Óû§Ãû,b.LoginName ºÅÂë,c.MenuTitle ±êÌâ,max(a.AccessTime)·ÃÎÊʱ¼ä from JfAccessLog a,OaUser b,JfMenu c where CONVERT(char,a.AccessTime,112)=CONVERT(char,GETDATE(),112) and a.UserId=b.UserId and a.MenuId=c.MenuId and a.MenuId=@menu group by a.UserName,b.LoginName,c.Menu ......
ÔÚƽʱµÄ¹¤×÷¹ý³ÌÖУ¬×÷ΪDBA½ÇÉ«¹ÜÀíÊý¾Ý¿â£¬Í·ÄÔÖеÄÓ¡ÏóÍùÍùÊÇÊý¾Ý¿âʵÀýÃû³Æ£¬¶ø²»»áÈ¥¹ØÐÄServerµÄIP£¬¶ø×÷ΪDeveloperµÄ½ÇÉ«£¬ËûÃÇÍùÍùÏëÖªµÀÖªµÀServer IpºÍ¶Ë¿ÚºÅ¡£ËùÒÔ£¬DBA»á¾³£±»Îʼ°µ½£ºXXXʵÀýµÄIPºÍ¶Ë¿ÚºÅÊÇʲô£¿
Õâ¸öÎÊÌ⣬µ±È»ÎÒÃÇ¿ÉÒÔLoginµ½OS²é¿´IP¡¢Ê¹ÓÃÅäÖƹÜÀí¹¤¾ß»ñÈ¡µ½¶Ë¿ÚºÅ¡£µ«ÊÇ£¬Õâ¸ö·½·¨·Ç ......
sqlserverÊý¾Ý¿â£ºjavaÁ¬½Ósqlserver2005Êý¾Ý¿âÐĵÃÌå»á
Ê×ÏȵÃÏÂÔØÇý¶¯³ÌÐòµ½Î¢ÈíÍøÕ¾ÏÂÔØMicrosoft SQL Server 2005 JDBC Driver 1.2¡¡¡¡½âѹMicrosoft SQL Server 2005 jdbc driver1.2.exe
µÃµ½sqljdbc.jar£¬ÓõÃʱºòÖ±½Ó¼Óµ½classpathÖÐÈ¥.
¡¡ÉèÖÃSQL Server·þÎñÆ÷
·ÀÖ¹³öÏÖ
com.mi ......