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

AspNetPagerÓëMSSQLº£Á¿·ÖÒ³´æ´¢¹ý³Ì½áºÏ

´æ´¢¹ý³ÌPagination£º
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[Pagination]
@tblName varchar(255), -- ±íÃû
@PKName varchar(255), -- ×Ö¶ÎÃû
@strGotFields varchar(1000) = '*' , --²éѯ×Ö¶ÎÃû
@PageSize int = 10, -- Ò³³ß´ç
@PageIndex int = 1, -- Ò³Âë
@OrderType bit = 0, -- ÉèÖÃÅÅÐòÀàÐÍ, ·Ç 0 ÖµÔò½µÐò
@strSort varchar(255) = '', --ÅÅÐò×Ö¶Î
@strWhere varchar(2000) = '', -- ²éѯÌõ¼þ (×¢Òâ: ²»Òª¼Ó where)
@isCount bit = 1 --È¡µÃ¼Ç¼ÌõÊý
AS
DECLARE @strSQL varchar(6000) -- Ö÷Óï¾ä
DECLARE @strTmp varchar(1000) -- ÁÙʱ±äÁ¿
DECLARE @strOrder varchar(500) -- ÅÅÐòÀàÐÍ
DECLARE @strCount varchar(1000)
DECLARE @fldName varchar(255)
DECLARE @sortName varchar(255)
DECLARE @countSQL varchar(1000)
SET @fldName = @PKName
IF @strSort != ''
BEGIN
SET @sortName = @strSort
END
ELSE
BEGIN
SET @sortName = @PKName
END
IF @isCount = 1
BEGIN
IF @strWhere != ''
BEGIN
SET @countSQL = 'select count(' + @fldName + ') from ' + @tblName + ' where ' + @strWhere
END
ELSE
BEGIN
SET @countSQL = 'select count(' + @fldName + ') from ' + @tblName
END
EXEC (@countSQL)
RETURN
END
ELSE
BEGIN
IF @OrderType != 0
BEGIN
SET @strTmp = '<(select min'
SET @strOrder = ' order by ' + @sortName + ' desc'
END
ELSE
BEGIN
SET @strTmp = '>(select max'
SET @strOrder = ' order by ' + @sortName +' asc'
END
SET @strSQL = 'select top ' + str(@PageSize) + @strGotFields + ' from '
+ @tblName + ' where ' + @fldName + '' + @strTmp + '('
+ @fldName + ') from (select top ' + str((@PageIndex-1)*@PageSize) + ' '
+ @fldName + ' from ' + @tblName + '' + @strOrder + ') as tblTmp)'
+ @strOrder
IF @strWhere != ''
SET @strSQL = 'select top ' + str(@PageSize) + @strGotFields + ' from '
+ @tblName + ' where ' + @fldName + '' + @strTmp + '('
+ @fldName + ') from (select top ' + str((@PageIndex-1)*@PageSize) + ' '
+ @fldName + ' from ' + @tblName + ' where ' + @strWhere + ' '
+ @strOrder + ')


Ïà¹ØÎĵµ£º

MemcacheºÍMsSQL½»»¥Á÷³Ìͼ


MemcacheºÍMsSQL½»»¥Á÷³Ìͼ
ÈçÉÏͼ£¬´«Í³µÄ²éѯ·½·¨ÊÇÖ±½Ó²éѯÊý¾Ý¿â£¬Êý¾Ý¿â½«½á¹û·µ»Ø¸ø²éѯÓï¾ä£¬¶øµ±ÓÐMemcacheÖм仺´æ²ãʱ£¬²éѯµÄÊÇMemcache»º´æÊý¾Ý£¬ÏÂÃæÏêϸÁ˽âMemcache¸÷ÀàÊý¾Ý²Ù×÷Ô­Àí£º
1£¬²éѯÊý¾Ý(select)£¬Ê×ÏÈͨ¹ýÖ¸¶¨µÄKey²éѯ(get)MemcacheÖм仺´æ²ãÊý¾Ý£¬Èç¹û´æÔÚÏà¶ÔÓ¦Êý¾Ý£¬ÔòÖ±½Ó»ñÈ¡³öÊý¾Ý½ ......

MSSQL¾­µäÓï¾ä

MSSQL¾­µäÓï¾ä
1.°´ÐÕÊϱʻ­ÅÅÐò:Select * from TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as
2.Êý¾Ý¿â¼ÓÃÜ:select encrypt('ԭʼÃÜÂë')
select pwdencrypt('ԭʼÃÜÂë')
select pwdcompare('ԭʼÃÜÂë','¼ÓÃܺóÃÜÂë') = 1--Ïàͬ£»·ñÔò²»Ïàͬ encrypt('ԭʼÃÜÂë')
select pwdencrypt('ԭʼÃÜÂë' ......

MSSQL varbinaryת»»³É×Ö·û´®

--> Title  : varbinaryת»»³É×Ö·û´®
--> Author : wufeng4552
--> Date   : 2009-12-15
declare @s varchar(20),@bin varbinary(1000)
select @s='www.CSDN.net',@bin=cast(@s as varbinary(1000))
declare @re varchar(1000),@i int
select @re='',@i=datalength(@bin)
while @i>0
&n ......

ÐéÄâ»úÉÏMSSQLÁ¬½ÓµÄÎÊÌâ

ÔÚµçÄÔÉÏ×°Á˸öÐéÄâ»ú£¬±¾»ú×°Á˸öMSSQL2000,ÔÚÐéÄâ»úÒ²×°Á˸öMSSQL2000£¬µ«Êǵ±Á¬½ÓÐéÄâ»úÉϵÄMSSQL£¬SQLÌáʾ³ö´í£¬ÎÞ·¨Á¬½Ó£¬¾õµÃºÜÆæ¹Ö£¬ÒòΪIPµØÖ·ÊDz»Í¬µÄ£¬×îºóÏëµ½Á˸ö°ì·¨£¬ÒòΪÊÇһ̨µçÄÔ£¬ËùÒԶ˿Ú1433Ö»ÓÐÒ»¸ö£¬±¾»úÕ¼ÁË1433£¬ÄÇôÐéÄâ»ú¾Íû·¨ÓÃÁË£¬Ïëµ½¾Í×ö£¬°ÑÐéÄâ»úµÄ¶Ë¿Ú¸Ä³ÉÁË1500¡£ÖØÆôµçÄÔ£¬µ«ÊÇ»¹ÊDz»Ä ......

MsSql³£ÓÃÈÕÆÚ¸ñʽ

SQL ServerÖÐÎÄ°æµÄĬÈϵÄÈÕÆÚ×Ö¶Îdatetime¸ñʽÊÇyyyy-mm-dd Thh:mm:ss.mmm
ÀýÈç:
select getdate()
2004-09-12 11:06:08.177
ÕûÀíÁËÒ»ÏÂSQL ServerÀïÃæ¿ÉÄܾ­³£»áÓõ½µÄÈÕÆÚ¸ñʽת»»·½·¨:
¾ÙÀýÈçÏÂ:
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select replace(replace(replace(CONVER ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ