SQL Server 2005 ÖеÄRow_Number()º¯Êý
±¾ÎÄÀ´×Ô£ºhttp://www.cnblogs.com/digjim/archive/2006/09/20/509344.html
ÎÒÃÇÖªµÀ£¬SQL Server 2005ºÍSQL Server 2000 Ïà±È½Ï£¬SQL Server 2005ÓкܶàÐÂÌØÐÔ¡£ÕâƪÎÄÕÂÎÒÃÇÒªÌÖÂÛÆäÖеÄÒ»¸öк¯ÊýRow_Number()¡£Êý¾Ý¿â¹ÜÀíÔ±ºÍ¿ª·¢ÕßÒѾÆÚ´ýÕâ¸öº¯ÊýºÜ¾ÃÁË£¬ÏÖÔÚÖÕÓڵȵ½ÁË£¡
ͨ³££¬¿ª·¢Õߺ͹ÜÀíÔ±ÔÚÒ»¸ö²éѯÀÓÃÁÙʱ±íºÍÁÐÏà¹ØµÄ×Ó²éѯÀ´¼ÆËã²úÉúÐкš£ÏÖÔÚSQL Server 2005ÌṩÁËÒ»¸öº¯Êý£¬´úÌæËùÓжàÓàµÄ´úÂëÀ´²úÉúÐкš£
ÎÒÃǼÙÉèÓÐÒ»¸ö×ÊÁÏ¿â[EMPLOYEETEST]£¬×ÊÁÏ¿âÖÐÓÐÒ»¸ö±í[EMPLOYEE]£¬Äã¿ÉÒÔÓÃÏÂÃæµÄ½Å±¾À´²úÉú×ÊÁϿ⣬±íºÍ¶ÔÓ¦µÄÊý¾Ý¡£
USE [MASTER]
GO
IF EXISTS (SELECT NAME from SYS.DATABASES WHERE NAME = N'EMPLOYEE TEST')
DROP DATABASE [EMPLOYEE TEST]
GO
CREATE DATABASE [EMPLOYEE TEST]
GO
USE [EMPLOYEE TEST]
GO
IF EXISTS SELECT * from SYS.OBJECTS HERE OBJECT_ID = OBJECT_ID(N'[DBO].[EMPLOYEE]') AND TYPE IN (N'U'))
DROP TABLE [DBO].[EMPLOYEE]
GO
CREATE TABLE EMPLOYEE (EMPID INT, FNAME VARCHAR(50),LNAME VARCHAR(50))
GO
INSERT INTO EMPLOYEE (EMPID, FNAME, LNAME) VALUES (2021110, 'MICHAEL', 'POLAND')
INSERT INTO EMPLOYEE (EMPID, FNAME, LNAME) VALUES (2021110, 'MICHAEL', 'POLAND')
INSERT INTO EMPLOYEE (EMPID, FNAME, LNAME) VALUES (2021115, 'JIM', 'KENNEDY')
INSERT INTO EMPLOYEE (EMPID, FNAME, LNAME) VALUES (2121000, 'JAMES', 'SMITH')
INSERT INTO EMPLOYEE (EMPID, FNAME, LNAME) VALUES (2011111, 'ADAM', 'ACKERMAN')
INSERT INTO EMPLOYEE (EMPID, FNAME, LNAME) VALUES (3015670, 'MARTHA', 'LEDERER')
INSERT INTO EMPLOYEE (EMPID, FNAME, LNAME) VALUES (1021710, 'MARIAH', 'MANDEZ')
GO
ÎÒÃÇ¿ÉÒÔÓÃÏÂÃæµÄ½Å±¾²éѯEMPLOYEE±í¡£
SELECT EMPID, RNAME, LNAME from EMPLOYEE
Õâ¸ö²éѯµÄ½á¹ûÓ¦¸ÃÈçͼ1.0
2021110
MICHAEL
POLAND
2021110
MICHAEL
POLAND
2021115
JIM
KENNEDY
2121000
JAMES
SMITH
2011111
ADAM
ACKERMAN
3015670
MARTHA
LEDERER
1021710
MARIAH
MANDEZ
ͼ1.0
ÔÚSQL Server 2005£¬Òª¸ù¾ÝÕâ¸ö±íÖеÄÊý¾Ý²úÉúÐкţ¬ÎÒͨ³£Ê¹ÓÃÏÂÃæµÄ²éѯ¡£
SELECT ROWID=IDENTITY(int,1,1) , EM
Ïà¹ØÎĵµ£º
Ò»£®ÊÓͼ(VIEW)
¶¨Ò壺ÊÓͼÊÇÒ»ÕÅÐéÄâµÄ±í£¬ÆäÄÚÈÝÊÇ´ÓÒ»ÕÅ»ò¶àÕűíÖвéѯµÃÀ´µÄ½á¹û¼¯¡£
ÃèÊö£ºÊÓͼÊÇ´æ´¢ÔÚϵͳĿ¼ÖеÄÐÅÏ¢£¬Ëý²¢Ã»ÓÐÕæÕý´æ´¢Êý¾Ý£¬¶øÊÇÒÑ´æ±íµÄͶӰ¡£ÊÓͼµÄÊôÐÔÊÇ°´ÕÕÒ»¸ö²éѯµÄ¹æ¶¨´ÓÒ»¸ö»òÕ߶à¸ö±íÖе¼³öµÄ£¬ÊÇÒÑ´æ±íµÄ¹ýÂËÆ÷¡£ËýÊÇÒ»ÕÅ“Ðé±í”£¬´ÓÒ»Õűí»òÕ߶àÕűíÖÐÅÉÉú³öÀ´µÄ£¬Æä ......
SQL×¢ÈëÊÇ×î³£¼ûµÄ¹¥»÷·½Ê½Ö®Ò»,Ëü²»ÊÇÀûÓòÙ×÷ϵͳ»òÆäËüϵͳµÄ©¶´À´ÊµÏÖ¹¥»÷µÄ,¶øÊdzÌÐòÔ±ÒòΪûÓÐ×öºÃÅжÏ,±»²»·¨
Óû§×êÁËSQLµÄ¿Õ×Ó,ÏÂÃæÎÒÃÇÏÈÀ´¿´ÏÂʲôÊÇSQL×¢Èë:
±ÈÈçÔÚÒ»¸öµÇ½½çÃæ,ÒªÇóÓû§ÊäÈëÓû§ÃûºÍÃÜÂë:
& ......
SQL ServerÁ¬½ÓÔ¶³ÌÊý¾ÝÔ´µÄ»ù±¾·½·¨ÓÐÏÂÃæÈýÖÖ£º
OPENDATASOURCE
: The OPENDATASOURCE function is used to
specify connection information for a remote data source by specifying
the OLE DB provider and an initialization string. OPENDATASOURCE can be
used directly within a SELECT, INSERT, UPDATE, or ......
СµÜÏëÎʸöÎÊÌ⣬ÔÚSQL Server 2005ÉÏ£¬½¨Á¢Ö÷¼üµÄͬʱ¾Í»áĬÈÏÔÚÖ÷¼üÉÏÉèÖþ۴ØË÷Òý£¬ÄÇôÄÜ·ñÔÚÒ»¸ö×Ö¶ÎÉÏÉèÖÃÖ÷¼üºÍΨһÐÔË÷Òý£¨Unique£©£¬µ«ÊǰѾ۴ØË÷ÒýÉèÖõ½ÁíÒ»¸ö×Ö¶ÎÉÏ£¿
¾Ù¸ö¼òµ¥µÄÀý×Ó£¬±ÈÈçÎÒÓиö±í½ÐTableTest£¬±íÀïÓÐÁ½¸ö×ֶΣ¬id,date£¬±¾À´idÊÇÖ÷¼üµÄ£¬ÎÒÏÖÔÚÏë°Ñ¾Û´ØË÷ÒýÉèÖõ½date×Ö¶ÎÉÏ¡£
ÎÒÏÈɾ³ýÖ ......
SQL Server 2008ÖеıíÖµÐͲÎÊý
×÷ÕߣºAl Tenhundfeld ÒëÕß Õź£Áú¡¡
±íÖµÐͲÎÊý£¨Table-valued parameters£©ÊÇSQL Server 2008ÖÐÒýÈëµÄÒ»ÖÖÐÂÌØÐÔ£¬ËüÌṩÁËÒ»ÖÖÄÚÖõķ½Ê½£¬Èÿͻ§¶ËÓ¦ÓÿÉÒÔֻͨ¹ýµ¥¶ÀµÄÒ»Ìõ²Î»¯ÊýSQLÓï¾ä£¬¾Í¿ÉÒÔÏòSQL Server·¢ËͶàÐÐÊý¾Ý¡£
±íÖ ......