Sql Server2005ÓÃRow_Number·ÖÒ³´æ´¢¹ý³ÌµÄÐÔÄÜʵ²â
Sql Server2005µÄÒ»¸öÐÂÌØÐÔ±ãÊÇÎÒµÈÁ˺ܾõÄRow_Number(),ÒÔǰÓÃOracleʱÓÃrownumberд·ÖÒ³´æ´¢¹ý³ÌºÜ·½±ã£º£©
ÏÂÃæÊÇÎÒ×öµÄÒ»¸öССµÄ²âÊÔ£¬²âÊÔÎÒÔÀ´ÔÚsql server2000ÏÂËùÓõķÖÒ³´æ´¢¹ý³ÌÓëʹÓÃRow_Number()±àдµÄ´æ´¢¹ý³ÌÔÚSql Server2005ÉϵÄÖ´ÐÐЧÂÊ...
Êý¾Ý±í£º
REATE TABLE [dbo].[test](
[UserId] [int] Primary Key IDENTITY(1,1) ,
[UserName] [nvarchar](256) ,
[Sex] [varchar](50) NOT NULL,
[Age] [int] NOT NULL,
[Address] [varchar](100) ,
[status] [bit] NULL,
[Email] [varchar](100) ,
[InsertDate] [datetime] NOT NULL
)
²åÈë1000k¼Ç¼
use temp
Go
declare @n int
set @n = 0
while @n<1000000
BEGIN
Insert Into test(UserName,Sex,Age,Address,status,Email,InsertDate)
Values('bbisky','ÄÐ','25','Öйú´«Ã½´óѧÏÖ´úÔ¶³Ì½ÌÓýÖÐÐÄ',1,'denghaibo@live.com',getdate())
Select @n = @n+1
END
Á½¸ö´æ´¢¹ý³Ì
ÔÀ´Ê¹ÓÃTopµÄ·ÖÒ³´æ´¢¹ý³Ì
Create proc [dbo].[test_PageById]
(
@pageIndex int,
@pageSize int
)
AS
SELECT TOP(@pageSize) *
from test
WHERE UserId <
(SELECT MIN(UserId) from (
SELECT TOP ((@pageIndex-1) * @pageSize) UserId
from test
ORDER BY UserId DESC)B )
ORDER BY UserId DESC
ʹÓÃRow_numberµÄ´æ´¢¹ý³Ì
CREATE proc [dbo].[test_PageByRowNumber]
(
@pageIndex int,
@pageSize int
)
AS
DECLARE @startRow int, @endRow int
Set @startRow = (@pageIndex - 1) * @pageSize +1
SET @endRow = @startRow + @pageSize -1
SELECT*
from (
SELECT *,ROW_NUMBER() OVER (ORDER BY UserId DESC) AS RowNumber
from test ) T
WHERE T.RowNumber BETWEEN @startRow AND @endRow
²âÊԺͽá¹û
SET STATISTICS io ON
SET STATISTICS time ON
go
EXEC test_PageByRowNumber 1000,50¡¡--RowNumber´æ´¢¹ý³Ì
go
SET STATISTICS profile OFF
SET STATISTICS io OFF
SET STATISTICS time OFF
/*½á¹û·ÖÎö*/
SQL Server ·ÖÎöºÍ±àÒëʱ¼ä:
CPU ʱ¼ä = 0 ºÁÃ룬ռÓÃʱ¼ä = 1 ºÁÃë¡£
SQL Server ·ÖÎöºÍ±àÒëʱ¼ä:
CPU ʱ¼ä = 0 ºÁÃ룬ռÓÃʱ¼ä = 1 ºÁÃë¡£
SQL Server Ö´ÐÐʱ¼ä:
CPU ʱ¼ä = 0 ºÁÃ룬ռÓÃʱ¼ä = 1 ºÁÃë¡£
SQL Server Ö´ÐÐʱ¼ä:
CPU ʱ¼ä = 0 ºÁÃ룬ռÓÃʱ¼ä = 1 ºÁÃë¡£
(50 ÐÐÊÜÓ°Ïì)
±í '
Ïà¹ØÎĵµ£º
/*
±êÌ⣺ÆÕͨÐÐÁÐת»»(version 2.0)
×÷Õߣº°®Ð¾õÂÞ.ع»ª
ʱ¼ä£º2008-03-09
µØµã£º¹ã¶«ÉîÛÚ
˵Ã÷£ºÆÕͨÐÐÁÐת»»(version 1.0)½öÕë¶Ôsql server 2000Ìṩ¾²Ì¬ºÍ¶¯Ì¬Ð´·¨£¬version 2.0Ôö¼Ósql server 2005µÄÓйØÐ´·¨¡£
ÎÊÌ⣺¼ÙÉèÓÐÕÅѧÉú³É¼¨±í(tb)ÈçÏÂ:
ÐÕÃû ¿Î³Ì ·ÖÊý
ÕÅÈý ÓïÎÄ 74
ÕÅÈý Êýѧ 83
ÕÅÈý ÎïÀí 93 ......
selectÓï¾äÖÐÖ»ÄÜʹÓÃsqlº¯Êý¶Ô×ֶνøÐвÙ×÷£¨Á´½Ósql server£©£¬
select ×Ö¶Î1 from ±í1 where ×Ö¶Î1.IndexOf("ÔÆ")=1;
ÕâÌõÓï¾ä²»¶ÔµÄÔÒòÊÇindexof£¨£©º¯Êý²»ÊÇsqlº¯Êý£¬¸Ä³Ésql¶ÔÓ¦µÄº¯Êý¾Í¿ÉÒÔÁË¡£
left£¨£©ÊÇsqlº¯Êý¡£
select ×Ö¶Î1 from ±í1 where charindex£¨'ÔÆ',×Ö¶Î1£©=1;
×Ö·û´®º¯Êý¶Ô¶þ½øÖÆÊý¾Ý¡¢×Ö·û´®º ......
Ó°ÏìÊý¾Ý¿â»¹ÔËٶȵÄÒòËØºÍÓ°ÏìÊý¾Ý¿â±¸·ÝËٶȵÄÒòËØÏàͬ¡£³ý´ËÖ®Í⣬¼ÙÈçÄãʹÓÃSQL Server 2005µÄ»°£¬Ä㻹¿ÉÒÔÆô¶¯ÁíÍâÒ»¸öÓÅ»¯ÈÎÎñÀ´»¹Ôµ±Ç°²»´æÔÚµÄÊý¾Ý¿â£¬ÔËÐл·¾³ÎªWindows XP£¬Windows 2003 Server »ò¸üа汾¡£
Perform Volume Maintenance Tasks
µ±Ä㻹ÔÒ»¸öеÄÍêÕûÊý¾Ý¿âÊÇ£¬SQL Server¶Á±¸·ÝÎļþÍ·£¬È»ºó´ ......
SQL Server 2005ΪXMLÌṩ±¾µØÖ§³Ö;ÏÖÔÚ¿ÉÒÔÔÚOPENXML½ÚµãÖÐʹÓÃÒ»¸ö´øÓÐnodes()º¯ÊýµÄXML×Ö¶ÎÀàÐͰÑÒ»¸öXMLÎļþת»¯ÎªÒ»¸öÐм¯¡£ÈÃÎÒÃÇÀ´¿´Ò»¸öʹÓÃOPENXMLµÄ¼òµ¥Àý×Ó£¬²¢ÏÔʾÈçºÎ°ÑËüת»¯ÎªÔÚSQL Server 2005ÖÐʹÓÃXML×Ö¶ÎÀàÐͺÍnodes()º¯Êý¡£
¡¡¡¡ÎªÁËʹÎÒÃǵÄÀý×Ó¼òµ¥»¯£¬ÎÒÃǽ«¼ÙÉèÎÒÃÇÐèÒªÖ´ÐÐijÖÖ»ùÓڲɹº¶©µ¥ÁÐ±íµ ......
*
sql xml ÈëÃÅ:
--by jinjazz
--http://blog.csdn.net/jinjazz
1¡¢xml: ÄÜÈÏÊ¶ÔªËØ¡¢ÊôÐÔºÍÖµ
2¡¢xpath: ѰַÓïÑÔ£¬ÀàËÆwind ......