SQL SERVER 2005·ÖÒ³´æ´¢¹ý³Ì
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[PE011_Page]
@TableName varchar(50), --±íÃû
@Fields varchar(5000) = '*', --×Ö¶ÎÃû(È«²¿×Ö¶ÎΪ*)
@OrderField varchar(5000), --ÅÅÐò×Ö¶Î(±ØÐë!Ö§³Ö¶à×Ö¶Î)
@sqlWhere varchar(5000) = Null,--Ìõ¼þÓï¾ä(²»ÓüÓwhere)
@pageSize int, --ÿҳ¶àÉÙÌõ¼Ç¼
@pageIndex int = 1 , --Ö¸¶¨µ±Ç°ÎªµÚ¼¸Ò³
@totalRecord int = 0 output,
@TotalPage int output --·µ»Ø×ÜÒ³Êý
AS
BEGIN
Begin Tran --¿ªÊ¼ÊÂÎñ
Declare @sql nvarchar(4000);
if @totalRecord<=0 begin
--¼ÆËã×ܼǼÊý
if (@SqlWhere='' or @sqlWhere=NULL)
set @sql = 'select @totalRecord = count(*) from ' + @TableName
else
set @sql = 'select @totalRecord = count(*) from ' + @TableName + ' with(nolock) where ' + @sqlWhere
EXEC sp_executesql @sql,N'@totalRecord int OUTPUT',@totalRecord OUTPUT--¼ÆËã×ܼǼÊý
end
--¼ÆËã×ÜÒ³Êý
select @TotalPage=CEILING((@totalRecord+0.0)/@PageSize)
if (@SqlWhere='' or @sqlWhere=NULL)
set @sql = 'Select * from (select ROW_NUMBER
Ïà¹ØÎĵµ£º
DATENAME([Year],
dbo.reservation.begintime) + N'Äê' + CAST(DATEPART([Month],
dbo.reservation.begintime) AS varchar) + N'ÔÂ' + DATENAME([Day],
dbo.reservation.begintime) + N'ÈÕ' + DATENAME([Hour], dbo.r ......
×î½üÓöµ½Ò»¸öÏîÄ¿£¬¿Í»§ÔÚ×ܲ¿Â¼ÈëÐÅÏ¢ºó£¬Êý¾ÝÐèҪͬ²½µ½ÏÂÊôµÄÈô¸É¸ö×ÓϵͳÖС£ÏÖÔÚ×ܲ¿µ¥¶ÀʹÓÃÒ»¸öÊý¾Ý¿â£¬ÏÂÊôµ¥Î»¸÷×ÔʹÓÃ×Ô¼ºµÄÊý¾Ý¿â¡£
¶ÔÓÚÕâ¸öÎÊÌ⣬Ïëµ½Á˼¸¸ö½â¾ö·½°¸£º
1¡¢×Ô¼ºÐ´´úÂë½â¾ö¡£¶¨ÒåºÃ·ÃÎÊÿ¸öÊý¾ ......
SQLÓÅ»¯²éѯ
ÊÕ²Ø
Êý¾Ý¿âµÄ²éѯÓÅ»¯¼¼Êõ
Êý¾Ý¿âϵͳÊǹÜÀíÐÅϢϵͳµÄºËÐÄ£¬»ùÓÚÊý¾Ý¿âµÄÁª»úÊÂÎñ´¦Àí£¨OLTP£©ÒÔ¼°Áª»ú·ÖÎö´¦Àí(OLAP)ÊÇÒøÐС¢ÆóÒµ¡¢Õþ¸®µÈ²¿ÃÅ×îÎªÖØÒªµÄ¼ÆËã»úÓ¦
ÓÃÖ®Ò»¡£´Ó´ó¶à ......
1. ¸´ÖƱí½á¹¹
Sql´úÂë
1. select * into B from A where 1=0;
select * into B from A where 1=0;
2.¸´ÖƱí¼Ç¼ ¸´ÖÆÄ³Ð©×Ö¶Î
Sql´úÂë
1. insert into B(a, b, c) select d, e, f from A;
insert into B(a, b, c) select d, e, f from A;
¸´Ö ......
×òÍí£¬µ½Î¢Èí¹Ù·½ÏÂÁËÒ»¸ö32°æ±¾µÄTrial°æ±¾¡£ÎļþÃûΪSQLFULL_x86_ENU.exe¡£Îļþ´óСΪ1.30G×óÓÒ¡£ÒòΪֻÓÐ32λһ¸ö°æ
±¾£¬±ÈSQL Server 2008ÄǸö3GµÄҪС¶àÁË¡£ºÇºÇ¡£
http://www.microsoft.com/sqlserver/2008/en/us/R2Downloads.aspx
ÏÂ
ÔØÍê³Éºó£¬ÏÈÐ¶ÔØÔÀ´µÄSQL Server 2008¡¡sp2,½á¹ûÕûÕûÔËÐÐÁËÁ½¸ ......