SQL Server 2005ÖеÄT SQLÔöÇ¿B
SQL2005ÖÐrow_number( )¡¢rank( )¡¢dense_rank( )¡¢ntile( )º¯ÊýµÄÓ÷¨(2) ÊÕ²Ø
SQL server 2005ÐÂÔöµÄ¼¸¸öº¯Êý,·Ö±ðÊÇrow_number( )¡¢rank( )¡¢,DENSE_RANK( )¡¢ntile( )ÏÂÃæÒÔʵÀý·Ö±ð¼òµ¥½²½â¡£
1.row_number( )
ÏÈÀ´µãÊý¾Ý,ÏȽ¨¸ö±í
SET NOCOUNT ON
CREATE TABLE Person(
FirstName VARCHAR(10),
Age INT,
Gender CHAR(1))
INSERT INTO Person VALUES ('Ted',23,'M')
INSERT INTO Person VALUES ('John',40,'M')
INSERT INTO Person VALUES ('George',6,'M')
INSERT INTO Person VALUES ('Mary',11,'F')
INSERT INTO Person VALUES ('Sam',17,'M')
INSERT INTO Person VALUES ('Doris',6,'F')
INSERT INTO Person VALUES ('Frank',38,'M')
INSERT INTO Person VALUES ('Larry',5,'M')
INSERT INTO Person VALUES ('Sue',29,'F')
INSERT INTO Person VALUES ('Sherry',11,'F')
INSERT INTO Person VALUES ('Marty',23,'F')
Ö±½ÓÓÃÀý×Ó˵Ã÷ÎÊÌâ:
SELECT ROW_NUMBER() OVER (ORDER BY Age) AS [Row Number by Age],
FirstName,
Age
from Person
³öÏÖµÄÊý¾ÝÈçÏÂ
Row Number by Age FirstName Age
-------------------------- ---------- --------
1 Larry 5
2  
Ïà¹ØÎĵµ£º
²½ÖèÊÇ£º
1£©Ìí¼Ó/ɾ³ý³ÌÐòÖг¹µ×ɾ³ýsql server¡£
2£©½«Ã»ÓÐɾ³ýµÄsql serverĿ¼Ҳɾ³ýµô¡£
3£©´ò¿ª×¢²á±í±à¼Æ÷£¬ÔÚHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session ManagerÖÐÕÒµ½PendingFileRenameOperationsÏîÄ¿£¬²¢É¾³ýËü¡£ÕâÑù¾Í¿ÉÒÔÇå³ý°²×°ÔݹÒÏîÄ¿¡£
4£©É¾³ý×¢²á±íÖиúsql serverÏà¹ØµÄ¼ü¡ ......
SQL³£ÓÃÓï¾ä
SQLÓï¾äÏÈǰдµÄʱºò£¬ºÜÈÝÒ×°ÑһЩÌØÊâµÄÓ÷¨Íü¼Ç£¬ÎÒÌØ´ËÕûÀíÁËÒ»ÏÂSQLÓï¾ä²Ù×÷¡£
Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk ......
´ó¼Ò¶¼ÖªµÀ£¬ÓÃPL/SQLÁ¬½ÓOracle£¬ÊÇÐèÒª°²×°Oracle¿Í»§¶ËÈí¼þµÄ¡£ÓÐûҪÏë¹ý²»°²×°Oracle¿Í»§¶ËÖ±½ÓÁ¬½ÓOracleÄØ£¿
ÆäʵÎÒÒ»Ö±ÏëÕâÑù×ö£¬ÒòΪÕâ¸ö¿Í»§¶ËʵÔÚÌ«ÈÃÈËÌÖÑáÁË£¡£¡£¡²»µ«»á°²×°Ò»¸öJDK£¬¶øÇÒ»¹»á°Ñ×Ô¼º·ÅÔÚ»·¾³±äÁ¿µÄ×îÇ°Ã棬»áÔì³É²»Ð ......
-- ²é¿´ORACLE Êý¾Ý¿âÖб¾Óû§ÏµÄËùÓбí
SELECT table_name from user_tables;
-- ²é¿´ORACLE Êý¾Ý¿âÖÐËùÓÐÓû§ÏµÄËùÓбí
select user,table_name from all_tables;
-- ²é¿´ORACLE Êý¾Ý¿âÖб¾Óû§ÏµÄËùÓÐÁÐ
select table_name,column_name from user_tab_columns;
-- ²é¿´ORACLE Êý¾Ý¿âÖб¾Óû§ÏµÄËùÓÐÁÐ
se ......
CLR Óû§¶¨Ò庯ÊýÖ»ÊÇÔÚ .NET ³ÌÐò¼¯Öж¨ÒåµÄ¾²Ì¬·½·¨¡£CREATE FUNCTION Óï¾äÒÑÀ©Õ¹ÎªÖ§³Ö´´½¨ CLR
Óû§¶¨Ò庯Êý¡£
1¡¢´´½¨Êý¾Ý¿âÏîÄ¿
¡¡¡¡
2¡¢Ìí¼ÓÓû§¶¨Ò庯Êý
¡¡¡¡
ÒÔÏÂÊÇÑÝʾ´úÂ룺
Code
using
System;
using
System.Data;
using
System.Data.SqlClient;
using
System.Data.Sql ......