¡¾×ª¡¿ ¡¾SQL¡¿ÐÐÁÐת»»
¡¾SQL¡¿ÐÐÁÐת»»
http://space.itpub.net/519536/viewspace-609167
Ò»¡¢ÁбäÐÐ
1.´´½¨²âÊÔ±ítest£¬²¢³õʼ»¯ÊµÑéÊý¾Ý
sec@ora10g> create table test (name_id varchar2(10), name varchar2(10));
sec@ora10g> insert into test values ('01','Andy1');
sec@ora10g> insert into test values ('01','Andy2');
sec@ora10g> insert into test values ('01','Andy3');
sec@ora10g> insert into test values ('01','Andy4');
sec@ora10g> insert into test values ('02','Steven1');
sec@ora10g> insert into test values ('02','Steven2');
sec@ora10g> insert into test values ('02','Steven3');
sec@ora10g> insert into test values ('02','Steven4');
sec@ora10g> commit;
2.²é¿´²âÊÔ±íÊý¾Ý
sec@ora10g> select * from test order by name_id;
NAME_ID NAME
---------- ----------------------------------------
01 Andy1
01 Andy4
01 Andy3
01 Andy2
02 Steven1
02 Steven4
02 Steven3
02 Steven2
8 rows selected.
3.ÎÒÃÇ°´ÕÕname_id²»Í¬Öµ½«¸Ã±íºáÏòת»»ÈçÏÂ
SELECT t1.name_id,
SUBSTR (MAX (SYS_CONNECT_BY_PATH (t1.NAME, ';')), 2) NAME
from (SELECT a.name_id, a.NAME,
ROW_NUMBER () OVER (PARTITION BY a.name_id ORDER BY a.NAME) rn
from TEST a) t1
START WITH t1.rn = 1
CONNECT BY t1.name_id = PRIOR t1.name_id AND t1.rn - 1 = PRIOR t1.rn
GROUP BY t1.name_id;
NAME_ID &nbs
Ïà¹ØÎĵµ£º
declare @XML XML
SET @XML='<root>
<OLDVALUE>
<H_Action id="1130">030</H_Action>
<D_Action>030</D_Action>
<OrderCompany>00220</OrderCompany>
<OrderNumber>10004035</OrderNumber> ......
ÔÚSQL Server2005ÖÐÓÐFOR XML Ó÷¨£¬¿ÉÒÔ½²Ò»¸ö±í×÷Ϊһ¸ö×ֶΡ£
ÎÒµÄÉè¼ÆÏë·¨Ö÷ÒªÊÇÓÃÔÚ1¶Ô¶àµÄ¹ØϵÖбí¶ÁÈ¡µÄÎÊÌâ¡£
±íA ±íB
ÔÚAÖÐÓÐÒ»Ìõ¼Ç¼¶øÔÚBÖÐÓжàÌõ¼Ç¼¿ÉÒÔ²ÎÕÕÏÂÃæµÄд·¨£º£¨ÎÒµÄÏîÄ¿ÖÐÓõ½µÄ£¬ÐÞ¸ÄÁË×Ö¶ÎÖ÷ÒªÊÇÑÝʾÓã©
select A.*,
(SELECT a, CAST(G_Univalence AS NVARCHAR(48)) AS G_Univa ......
ÒÔϵļ¼ÇÉÖ»Õë¶ÔPL/SQL Developer 6ÒÔÉÏ°æ±¾£¬°æ±¾5Ö»ÓÐÆäÖеIJ¿·ÖÌØÐÔ¡£
1£¬ÓÒ¼ü²Ëµ¥
ÔÚPL/SQL Developer£¨ÏÂÃæ¼ò³ÆPLD£©ÖеÄÿһ¸öÎı¾±à¼´°¿Ú£¬ÈçSQL Window£¬Command WindowºÍPorgram Window£¬ÓÒ¼üµã»÷ij¸ö¶ÔÏóÃû³Æ£¬»áµ¯³öÒ»¸ö°üº¬²Ù×÷¶ÔÏóÃüÁîµÄ²Ëµ¥£¬ÎÒÃÇÕâÀï³Æ֮ΪÓÒ¼ü²Ëµ¥¡£ÈçÏÂͼ£º
¶ÔÏóÀàÐÍ¿ÉÒÔÊÇ±í£¬ÊÓͼ£ ......
·Ö²¼Ê½²éѯ
OPENROWSET
´ÓExcelÈ¡Êý¾Ý
SELECT * from OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=d:\1.xls',[Sheet1$])
´ÓOracleÈ¡Êý¾Ý
SELECT * from OPENROWSET('MSDAORA.1','NetServiceName ......
--»ñµÃµ±Ç°ËùÓÐÇý¶¯Æ÷
exec master.dbo.xp_availablemedia
--»ñµÃ×ÓĿ¼Áбí
exec master.dbo.xp_subdirs 'c:\'
--»ñµÃËùÓÐ×ÓĿ¼µÄĿ¼Ê÷½á¹¹
exec master.dbo.xp_dirtree 'c:\'
--¶©ÔÄÎļþɾ³ý
declare @tempTable table (Cont varchar(50))
declare @strTemp varchar(50)
declare @dirPath varchar(50)
declar ......