Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

sql ´æ´¢¹ý³Ì ·ÖÒ³

-- FUN:´æ´¢¹ý³Ì·ÖÒ³
-- @Table nvarchar(255), -- ±íÃû
-- @Fields nvarchar(1000) = ' * ', -- ÐèÒª·µ»ØµÄÁÐ
-- @OrderField nvarchar(255), -- ÅÅÐòµÄ×Ö¶ÎÃû,Ò»°ãΪΨһ±êʶ
-- @OrderType bit = 0, -- ÉèÖÃÅÅÐòÀàÐÍ, ·Ç 0 ÖµÔò½µÐò
-- @PageSize int = 10, -- ÿҳÓжàÉÙÌõ¼Ç¼
-- @PageIndex int = 1, -- µÚ¼¸Ò³
-- @Count int output, -- ·µ»Ø¼Ç¼×ÜÊý 
-- @StrWhere nvarchar(1500) -- ²éѯÌõ¼þ (×¢Òâ: ²»Òª¼Ó where,³õʼ»¯Îª1=1ʹµÃ²éѯÌõ¼þÓÀÔ¶²»Îª¿Õ)
----------------------------------------------------------
ALTER PROC [dbo].[PR_pages]
(
 @Table nvarchar(4000), -- ±íÃû
 @Fields nvarchar(1000) = ' * ', -- ÐèÒª·µ»ØµÄÁÐ
 @OrderField nvarchar(255), -- ÅÅÐòµÄ×Ö¶ÎÃû,Ò»°ãΪΨһ±êʶ
 @OrderType bit = 0, -- ÉèÖÃÅÅÐòÀàÐÍ, ·Ç 0 ÖµÔò½µÐò
 @PageSize int = 10, -- ÿҳÓжàÉÙÌõ¼Ç¼
 @PageIndex int = 1, -- µÚ¼¸Ò³
 @StrWhere nvarchar(1500), -- ²éѯÌõ¼þ (×¢Òâ: ²»Òª¼Ó where,³õʼ»¯Îª1=1ʹµÃ²éѯÌõ¼þÓÀÔ¶²»Îª¿Õ)
 @Count int output -- ·µ»Ø¼Ç¼×ÜÊý 
)
AS
BEGIN
 DECLARE @StrSQL nvarchar(4000)  -- Ö÷Óï¾ä
 DECLARE @StrTmp nvarchar(110) -- ÁÙʱ±äÁ¿
 DECLARE @StrOrder nvarchar(400) -- ÅÅÐòÀàÐÍ
 DECLARE @SumSql nvarchar(4000) -- ¼Ç¼×ÜÊý
 --SET @StrWhere = ' 1=1 '
 -- Ö´ÐÐ×ÜÊýͳ¼Æ
 SET @SumSql = 'SELECT @Count = COUNT(0) from ' + @Table + ' WHERE 1=1 ' + @StrWhere
 EXEC sp_executesql @SumSql,N'@Count int output',@Count output -- ¼Ç¼×ÜÊý
 -- Èç¹û@OrderType²»ÊÇ0£¬¾ÍÖ´ÐнµÐò
 IF @OrderType != 0
  BEGIN
   SET @StrTmp = ' <(SELECT MIN'
   SET @StrOrder = ' ORDER BY [' + @OrderField + '] DESC'
  END
  ELSE
  BEGIN
   SET @StrTmp = ' >(SELECT MAX'
   SET @StrOrder = ' ORDER BY [' + @OrderField + '] ASC'
  END
 -- Èç¹ûÊǵÚÒ»Ò³¾ÍÖ´ÐÐÒÔÏ´úÂ룬¼Ó¿ìÖ´ÐÐËÙ¶È
 IF @PageIndex = 1
  BEGIN
   SET @StrSQL = 'SELECT TOP ' + STR(@Pag


Ïà¹ØÎĵµ£º

sql serverºÍoracleÐÐתÁеÄÒ»ÖÖµäÐÍ·½·¨

sql serverºÍoracleÐÐתÁеÄÒ»ÖÖµäÐÍ·½·¨
ǰÑÔ£ºÍøÉÏÓв»ÉÙÎÄÕÂÊǽ²ÐÐתÁе쬵«ÊǴ󲿷ֶ¼ÊÇÖ±½ÓÌù´úÂ룬ºöÊÓÁËÖмä¹ý³Ì£¬±¾ÈË×Ô¼ºË¼¿¼ÁËÏÂΪʲôҪÕâÑùʵÏÖ£¬²¢ÇÒ×öÁËÈçϵıʼǣ¬¶ÔÓÐЩ¶®µÄÈËÀ´Ëµ¿ÉÄÜûÓмÛÖµ£¬Ï£Íû¶Ô»¹²»¶®µÄÈËÓÐÒ»µã½è¼øÒâÒå¡£
¶ÔÓÚÓÐЩҵÎñÀ´Ëµ£¬Êý¾ÝÔÚ±íÖеĴ洢ºÍÆä×îÖÕµÄGrid±íÏÖÇ¡ºÃÏ൱ÓÚ°ÑÔ ......

¹ØÓÚÍøÕ¾SQL×¢ÈëµÄÎÊÌâ,ÒÔ¼°½â¾ö°ì·¨


×î½ü·¢ÏÖÎÒÃǹ«Ë¾µÄASP.NETµÄ´úÂëÓÐÆ´½ÓSQLÓï¾äµÄϰ¹ß£¡ÕâÊǷdz£Î£Ïյġ£ÒÔÏÂÎÒ¾ÙÀý˵Ã÷Ò»ÏÂ
Àý×Ó1£º
statement := "SELECT * from users WHERE name = '" + userName + "'; "
½«Óû§Ãû±äÁ¿(¼´username)ÉèÖÃΪ£º
a' or 't'='t£¬´ËʱԭʼÓï¾ä·¢ÉúÁ˱仯£º
SELECT * from users WHERE name = 'a' OR 't'='t';
Èç¹ûÕâ ......

ÔÚSQL Server 2005ÖÐÓô洢¹ý³ÌʵÏÖËÑË÷¹¦ÄÜ


ÏÖÔںܶàÍøÕ¾¶¼ÌṩÁËÕ¾ÄÚµÄËÑË÷¹¦ÄÜ£¬Óеĺܼòµ¥ÔÚSQLÓï¾äÀï¼ÓÒ»¸öÌõ¼þÈ磺where names like ‘%words%’¾Í¿ÉÒÔʵÏÖ×î»ù±¾µÄËÑË÷ÁË¡£
    ÎÒÃÇÀ´¿´¿´¹¦ÄÜÇ¿´óÒ»µã£¬¸´ÔÓÒ»µãµÄËÑË÷ÊÇÈçºÎʵÏֵģ¨ÔÚSQL¡¡£Ó£Å£Ò£Ö£Å£Ò£²£°£°£¯£²£°£°£µÍ¨¹ý´æ´¢¹ý³ÌʵÏÖËÑË÷Ëã·¨£©¡£
    ÎÒÃÇ ......

SQL°²×°ÎÊÌâ ÎÞ·¨»ñÈ¡ASPNETÕË»§µÄϵͳÕË»§ÐÅÏ¢

°²×°SQL Server2005 ÎÊÌâÐÅÏ¢£º
“SQL Server °²×°³ÌÐòÎÞ·¨»ñÈ¡ ASPNET ÕÊ»§µÄϵͳÕÊ»§ÐÅÏ¢”
½â¾ö°ì·¨£º
ÓÃaspnet_regiisʵÓù¤¾ßÐ¶ÔØºÍÖØÐ°²×°Ò»Ï¾ͿÉÒÔÁË¡£
¾ßÌåµÄ²Ù×÷£º
1¡¢½øÈëCMD£º
C:\windows\microsoft.net\framework\v2.0.50727Îļþ¼ÐÏ£¬ÔËÐÐaspnet_regiis -uÐ¶ÔØ
È»ºóÔËÐÐaspnet_regiis -i Ö ......

¹ØÓÚ³ÌÐò´úÂëÖеÄSQLÓï¾ä

ÔÚ³ÌÐòÖÐÓÐЩ²éѯÓï¾äÏà¶Ô½Ï³¤£¬¿ÉÒÔ½«Óï¾äµ¥¶ÀдÔÚÒ»¸öXXX.sqlÎļþÖУ¬ÔÚ³ÌÐòÖжÁÈ¡SQLÎļþ
¾ßÌåÉæ¼°µ½
import java.io.File;
import org.apache.commons.io.FileUtils;
import java.net.URL;
URL resourceUrl = XXXX.class.getClassLoader().getResource(SQL_PATH+sqlName);//SQL_PATH¾ßÌåSQLÎļþ´æÔÚ·¾¶£¬sqlName¼ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ