Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQL 2005ÒçÓÃÖ®£º·Ö²ðÁÐÖµ

ÎÊÌâÃèÊö£º
Óбítb, ÈçÏÂ:
id          values
----------- -----------
1           aa,bb
2           aaa,bbb,ccc
Óû°´,·Ö²ðvaluesÁÐ, ·Ö²ðºó½á¹ûÈçÏÂ:
id          value
----------- --------
1           aa
1           bb
2           aaa
2           bbb
2           ccc
1. ¾ÉµÄ½â¾ö·½·¨
SELECT TOP 8000
    id = IDENTITY(int, 1, 1)
INTO #
from syscolumns a, syscolumns b
SELECT
    A.id,
    SUBSTRING(A.[values], B.id, CHARINDEX(',', A.[values] + ',', B.id) - B.id)
from tb A, # B
WHERE SUBSTRING(',' + A.[values], B.id, 1) = ','
DROP TABLE #
-- 2. еĽâ¾ö·½·¨
-- ʾÀýÊý¾Ý
DECLARE @t TABLE(id int, [values] varchar(100))
INSERT @t SELECT 1, 'aa,bb'
UNION ALL SELECT 2, 'aaa,bbb,ccc'
-- ²éѯ´¦Àí
SELECT
    A.id, B.value
from(
    SELECT id, [values] = CONVERT(xml,
            '<root><v>' + REPLACE([values], ',', '</v><v>') + '</v></root>')
    from @t
)A
OUTER APPLY(
    SELECT value = N.v.value('.', 'varchar(100)')
    from A.[values].nodes('/root/v') N(v)
)B
/*--½á¹û
id          value
----------- --------
1           aa
1           bb
2           aaa
2       &nbs


Ïà¹ØÎĵµ£º

SQL°²×°ÎÊÌâ ÎÞ·¨»ñÈ¡ASPNETÕË»§µÄϵͳÕË»§ÐÅÏ¢

°²×°SQL Server2005 ÎÊÌâÐÅÏ¢£º
“SQL Server °²×°³ÌÐòÎÞ·¨»ñÈ¡ ASPNET ÕÊ»§µÄϵͳÕÊ»§ÐÅÏ¢”
½â¾ö°ì·¨£º
ÓÃaspnet_regiisʵÓù¤¾ßÐ¶ÔØºÍÖØÐ°²×°Ò»Ï¾ͿÉÒÔÁË¡£
¾ßÌåµÄ²Ù×÷£º
1¡¢½øÈëCMD£º
C:\windows\microsoft.net\framework\v2.0.50727Îļþ¼ÐÏ£¬ÔËÐÐaspnet_regiis -uÐ¶ÔØ
È»ºóÔËÐÐaspnet_regiis -i Ö ......

ÍÆ¼ö̽ÌÖÕ䲨¡¾¾­µäSQLÓï¾ä´óÈ«¡¿

ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
¡¡¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
......

ÈýÖÖSQL·ÖÒ³·¨¡¾×ªÌû¡¿

Ó¦Ò»¸öÅóÓѵÄÒªÇó£¬ÌùÉÏÊղصÄSQL³£Ó÷ÖÒ³µÄ°ì·¨¡«¡«

±íÖÐÖ÷¼ü±ØÐëΪ±êʶÁУ¬[ID] int IDENTITY (1,1)

1.·ÖÒ³·½°¸Ò»£º(ÀûÓÃNot InºÍSELECT TOP·ÖÒ³)

Óï¾äÐÎʽ£º 
SELECT TOP Ò³¼Ç¼ÊýÁ¿ *
from ±íÃû
WHERE (ID NOT IN
  (SELECT TOP (ÿҳÐÐÊý*(Ò³Êý-1)) ID
  from ± ......

DB2 SQL PL½éÉÜ


DB2 SQL PL
SQL PLÊÇDB2ËùÖ§³ÖµÄ¹ý³Ì»¯ÓïÑÔ£¬ËüÊÇSQL/PSM±ê×¼µÄÒ»¸ö×Ó¼¯¡£Æä¸ù¾ÝÓ¦Ó÷¶Î§²»Í¬£¬ÓÖ·ÖΪInline SQL PL£¬Embeded SQL PLºÍCompiled SQL PL¡£
Inline SQL PL
ÊÊÓ÷¶Î§£º´¥·¢Æ÷¡¢º¯ÊýºÍ·½·¨£¬Ö§³Ö²¿·ÖSQL PL£¬Ê¹ÓÃʱҪעÒâһЩÏÞÖÆ
Óï·¨¹æÔò£ºBEGIN ATOMIC ... END
Embeded SQL PL
ÊÊÓ÷¶Î§£ºÇ¶Èëʽ£¬Åäº ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ