Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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²éѯÓÅ»¯


1¡¢    ÓóÌÐòÖУ¬±£Ö¤ÔÚʵÏÖ¹¦ÄܵĻù´¡ÉÏ£¬¾¡Á¿¼õÉÙ¶ÔÊý¾Ý¿âµÄ·ÃÎÊ´ÎÊý£»Í¨¹ýËÑË÷²ÎÊý£¬¾¡Á¿¼õÉÙ¶Ô±íµÄ·ÃÎÊÐÐÊý,×îС»¯½á¹û¼¯£¬´Ó¶ø¼õÇáÍøÂ縺µ££»Äܹ»·Ö¿ªµÄ²Ù×÷¾¡Á¿·Ö¿ª´¦Àí£¬Ìá¸ßÿ´ÎµÄÏìÓ¦Ëٶȣ»ÔÚÊý¾Ý´°¿ÚʹÓÃSQLʱ£¬¾¡Á¿°ÑʹÓõÄË÷Òý·ÅÔÚÑ¡ÔñµÄÊ×ÁУ»Ëã·¨µÄ½á¹¹¾¡Á¿¼òµ¥£»ÔÚ²éѯʱ£¬²»Òª¹ý¶àµØʹÓà ......

SQLÖÐÈçºÎÓÃÒ»¸ö±í¸üÐÂÁíÒ»¸ö±í

for ACCESS :
update a, b set a.name=b.name1 where a.id=b.id
for SQL Server:
"update a set a.name=b.name1 from a,b where a.id=b.id"
update   a   set   a.status=b.status  
  from   table1   a,table2   b  
&nbs ......

SQL Mirror HA(SQL serverµÄ¸ß¿ÉÓÃÐÔ)[תÔØ]


¶ÔSQL Server 2008 ½øÐÐMirrorµÄ»ù±¾ÅäÖü°°²×°¡£
×¼±¸¹¤×÷
1. Principal ÓëMirror ÒÔ¼° Witness Èý̨ʵÀý¶¼°²×°ÎªÏàͬ°æ±¾£¬Ä¿Ç°Êǵ½SQL Server 2008 SP1¡£
2. ÐèÒªÓÐÒ»¸öÓòÕÊ»§·Ö±ðÌí¼Óµ½ Èý̨Êý¾Ý¿âʵÀýËùÔÚµÄServer µÄ Administrators×é¡¢ÒÔ¼°SQL Server Ïà¹ØµÄ×éÖУ» ÓÉÓÚ¾ßÌåµÄ×éµÄ¹¦Äܲ»Çå³þ£¬Òò´Ë½¨ÒéËùÓ ......

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


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

±ðÈöÔSql Server µÄÐÔÄܲâÊÔÊý¾ÝÃÔ»óÄã

Êý¾Ý¿âµÄÐÔÄܲâÊÔ¿ÉÒÔ°ïÖúÄãÌáÇ°ÖªµÀÄãµÄϵͳµÄ¸ºÔØÄÜÁ¦£¬¿ÉÒÔ°ïÖúÄã¸Ä½øϵͳµÄʵʩ»òÉè¼Æ£¬¿ÉÒÔ°ïÖúÄãÈ·¶¨Ò»Ð©Éè¼ÆºÍ±à³ÌÔ­Ôò. µ«ÊÇ£¬ÕâÀïÃæÒ²ÓÐÏÝÚå. Èç¹û²»Ð¡ÐÄ£¬Äã»á×Ô¼º°Ñ×Ô¼ºÏݽøÈ¥£¬È´×îÖÕ²»Ã÷°×ÊÇʲôԭÒò. ÕâÀÎÒÄÃһλÏÈÉúΪÀý£¬À´¿´¿´ËûÔõô×Ô¼º°Ñ×Ô¼º¸ãºýÍ¿µÄ.
×î½ü, ÏëÆðÔÚ´æ´¢¹ý³ÌÖо¿¾¹ÊÇʹÓÃÁÙʱ±í»¹ÊÇÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ