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

ÎÒÏëÓÃÒ»ÌõSQLÏÔʾÕâÑùµÄ½á¹û

²»ÖªµÀÕâÑùµÄÒªÇóÄܲ»ÄÜʵÏÖ£¿
±ÈÈçÎÒÓÐÒ»ÕűíT1£¬ÀïÃæÖ»ÓÐÒ»¸ö×Ö¶Î1
ÀïÃæÓÐ100Ìõ¼Ç¼£¬ÈçÏÂËùʾ£º
×Ö¶Î1
A1
A2
A3
A4
...
A100
ÎÒÏëÓÃÒ»ÌõSQLÏÔʾÕâÑùµÄ½á¹û
µÚÒ»ÁР   µÚ¶þÁР   ...        µÚÊ®ÁÐ
A1        A11                  A91
A2        A12                  A92
A3        A13                  A93
...        ...                  ...
A10        A20                  A100
²»Öª¿É·ñʵÏÖ£¿µ±È»£¬Ò²²»Ò»¶¨·Ö³ÉÊ®ÁУ¬¿ÉÄÜÊÇÎåÁеȵȣ¬Çë¸ßÊִͽ̡£Ð»Ð»
--¼ÙÉè×ֶβ»´æÔÚÏàֵͬ.
select
  max(case (px - 1) % 10 when 0 then ×Ö¶Î1 else '' end) [c1],
  max(case (px - 1) % 10 when 1 then ×Ö¶Î1 else '' end) [c2],
  max(case (px - 1) % 10 when 2 then ×Ö¶Î1 else '' end) [c3],
  max(case (px - 1) % 10 when 3 then ×Ö¶Î1 else '' end) [c4],
  max(case (px - 1) % 10 when 4 then ×Ö¶Î1 else '' end) [c5],
  max(case (px - 1) % 10 when 5 then ×Ö¶Î1 else '' end) [c6],
  max(case (px - 1) % 10 when 6 then ×Ö¶Î1 else '' end) [c7],
  max(case (px - 1) % 10 when 7 then ×Ö¶Î1 else '' end) [c8],
  max(case (px - 1) % 10 when 8 then ×Ö¶Î1 else '' end) [c9],
  max(case (px - 1) % 10 when 9 then ×Ö¶Î1 else '' end) [c10]
from
(
  select * , px = (select count(1) from t1 where ×Ö¶Î1 < t.×Ö¶Î1) + 1 from t1 t
) m
group by (px - 1) / 10
--Èç¹û×ֶδæÔÚÏàֵͬ.
--sql 2000ÐèҪʹÓÃÁÙʱ±í
select * , px = identity(int,1,1) into tmp from t1
select
  max(case (px - 1) % 10 when 0 then ×Ö¶Î1 else '' end) [c1],
  max(case (px - 1) % 10 when 1 then ×Ö¶Î1 else '' end) [c2],
  max(case (px - 1) % 10 when 2 then ×Ö¶Î1 else '' end) [c3],
  m


Ïà¹ØÎĵµ£º

sqlÓï¾äµ¼Èëµ¼³ö´óÈ«

SELECT * into newtable
from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
  'Data Source="c:\aaaa.xls";User ID=Admin;Password=;Extended properties=Excel 11.0')...[Sheet1$]
/******* µ¼³öµ½excel
¡¡¡¡exec master..xp_cmdshell 'bcp settledb.dbo.shanghu out c:\temp1.xls -c -q -s"gnetdata/gnetdata" - ......

SQL 2005ÆôÓÃ×é¼þAd Hoc Distributed Queries

SQL Server ×èÖ¹Á˶Ô×é¼þ 'Ad Hoc Distributed Queries' µÄ STATEMENT'OpenRowset/OpenDatasource' µÄ·ÃÎÊ£¬ÒòΪ´Ë×é¼þÒÑ×÷Ϊ´Ë·þÎñÆ÷°²È«ÅäÖõÄÒ»²¿·Ö¶ø±»¹Ø±Õ¡£ÏµÍ³¹ÜÀíÔ±¿ÉÒÔͨ¹ýʹÓà sp_configure ÆôÓà 'Ad Hoc Distributed Queries'¡£ÓйØÆôÓà 'Ad Hoc Distributed Queries' µÄÏêϸÐÅÏ¢£¬Çë²ÎÔÄ SQL Server Áª»ú´ÔÊéÖÐ ......

¹ØÓÚSql PromptÆƽâµÄ·½·¨

Ç°²»¾Ã¿´µ½Í¬ÊÂÔÚÓÃSql Prompt3.9£¬¾õµÃÂù·½±ãµÄ¡£¸øÎÒÃÇд³ÌÐòÄÜʡϲ»ÉÙÁ¦Æø¡£·½±ã£¬sql´úÂë¿´ÆðÀ´ÓÖ¼ò½é¡£ÖµµÃÍƼö¡£http://www.red-gate.com/ÕâÊÇËüµÄ¹ÙÍø£¬ÊÇÒ»¿îÊշѵÄÈí¼þ¡£Õýʽ°æ±¾ÏÂÔØÏÂÀ´Ö»ÄÜʹÓÃ14Ìì¡£·Ï»°²»ËµÁË£¬ÏÈ¿´ÏÂЧ¹ûͼ£º
»¹²»´í°¡¡£
½ÓÏÂÀ´½éÉÜÏÂÆƽâµÄ·½·¨£¬Ïȵ½¹ÙÍø°Ñ×îаæ(ÏÖÔÚÒѾ­ÊÇ3.9ÁË)ÏÂÏÂÀ ......

¸øSQL Server .LDF Îļþ¼õ·Ê

  Èç¹ûÔ­À´µÄÊý¾Ý¿â¿ÉÓ㬷ÖÀëÊý¾Ý¿âºó£¬Ö»¸½¼ÓÊý¾ÝÎļþ£¬²»¸½¼ÓÈÕÖ¾   
  Èç¹û²»¿ÉÓã¬Ö»ÄÜÂýÂýµÈ»¹Ô­²Ù×÷Íê³ÉÁË   
    
  ÈÕÖ¾ÎļþÌ«´óÁË£¬Ó¦¸Ã¶¨ÆÚÕûÀíÈÕÖ¾   
    
  --ѹËõÈÕÖ¾¼°Êý¾Ý¿âÎļþ´óС   
  &n ......

sqlÓï¾äÖÐleft join¡¢inner joinÖеÄonÓëwhereµÄÇø±ð

table a(id, type):
id     type 
----------------------------------
1      1         
2      1          
3   &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ