½«ExcelÖеÄÊý¾Ýµ¼Èëµ½SQL Server 2000Êý¾Ý¿âÖÐ
½«ExcelÖеÄÊý¾Ýµ¼Èëµ½SQL Server 2000Êý¾Ý¿âÖÐ
1¡¢´ò¿ªÆóÒµ¹ÜÀíÆ÷£¬´ò¿ªÒªµ¼ÈëÊý¾ÝµÄÊý¾Ý¿â£¬ÔÚ±íÉÏ°´ÓÒ¼ü£¬ËùÓÐÈÎÎñ-->µ¼ÈëÊý¾Ý£¬µ¯³öDTSµ¼Èë/µ¼³öÏòµ¼£¬°´ ÏÂÒ»²½ £¬
2¡¢Ñ¡ÔñÊý¾ÝÔ´ Microsoft Excel 97-2000£¬ÎļþÃû Ñ¡ÔñÒªµ¼ÈëµÄxlsÎļþ£¬°´ ÏÂÒ»²½ £¬
3¡¢Ñ¡ÔñÄ¿µÄ ÓÃÓÚSQL Server µÄMicrosoft OLE DBÌṩ³ÌÐò£¬·þÎñÆ÷Ñ¡Ôñ±¾µØ(Èç¹ûÊDZ¾µØÊý¾Ý¿âµÄ»°£¬Èç VVV)£¬Ê¹ÓÃSQL ServerÉí·ÝÑéÖ¤£¬Óû§Ãûsa£¬ÃÜÂëΪ¿Õ£¬Êý¾Ý¿âÑ¡ÔñÒªµ¼ÈëÊý¾ÝµÄÊý¾Ý¿â£¨Èç client£©£¬°´ ÏÂÒ»²½ £¬
4¡¢Ñ¡Ôñ ÓÃÒ»Ìõ²éѯָ¶¨Òª´«ÊäµÄÊý¾Ý£¬°´ ÏÂÒ»²½ £¬
5¡¢°´ ²éѯÉú³ÉÆ÷£¬ÔÚÔ´±íÁбíÖУ¬ÓÐÒªµ¼ÈëµÄxlsÎļþµÄÁУ¬½«¸÷ÁмÓÈëµ½ÓÒ±ßµÄ Ñ¡ÖеÄÁÐ ÁбíÖУ¬ÕâÒ»²½Ò»¶¨Òª×¢Ò⣬¼ÓÈëÁеÄ˳ÐòÒ»¶¨ÒªÓëÊý¾Ý¿âÖÐ×ֶζ¨ÒåµÄ˳ÐòÏàͬ£¬·ñÔò½«»á³ö´í£¬°´ ÏÂÒ»²½ £¬
6¡¢Ñ¡ÔñÒª¶ÔÊý¾Ý½øÐÐÅÅÁеÄ˳Ðò£¬ÔÚÕâÒ»²½ÖÐÑ¡ÔñµÄÁоÍÊÇÔÚ²éѯÓï¾äÖÐ order by ºóÃæËù¸úµÄÁУ¬°´ ÏÂÒ»²½ £¬
7¡¢Èç¹ûҪȫ²¿µ¼È룬ÔòÑ¡Ôñ È«²¿ÐУ¬°´ ÏÂÒ»²½£¬
8¡¢Ôò»á¿´µ½¸ù¾ÝÇ°ÃæµÄ²Ù×÷Éú³ÉµÄ²éѯÓï¾ä£¬È·ÈÏÎÞÎóºó£¬°´ ÏÂÒ»²½£¬
9¡¢»á¿´µ½ ±í/¹¤×÷±í/ExcelÃüÃûÇøÓò ÁÐ±í£¬ÔÚ Ä¿µÄ ÁУ¬Ñ¡ÔñÒªµ¼ÈëÊý¾ÝµÄÄǸö±í£¬°´ ÏÂÒ»²½£¬
10¡¢Ñ¡Ôñ Á¢¼´ÔËÐУ¬°´ ÏÂÒ»²½£¬
11¡¢»á¿´µ½Õû¸ö²Ù×÷µÄÕªÒª£¬°´ Íê³É ¼´¿É¡£
Ïà¹ØÎĵµ£º
--¾ÛºÏº¯Êý
use pubs
go
select avg(distinct price) --Ëãƽ¾ùÊý
from titles
where type='business'
go
use pubs
go
select max(ytd_sales) --×î´óÊý
from titles
go
use pubs
go
select min(ytd_sales) --×îÐ¡Ê ......
1. Group By Óï¾ä¼ò½é£º
Group ByÓï¾ä´ÓÓ¢ÎĵÄ×ÖÃæÒâÒåÉÏÀí½â¾ÍÊÇ“¸ù¾Ý(by)Ò»¶¨µÄ¹æÔò½øÐзÖ×é(Group)”¡£ËüµÄ×÷ÓÃÊÇͨ¹ýÒ»¶¨µÄ¹æÔò½«Ò»¸öÊý¾Ý¼¯»®·Ö³ÉÈô¸É¸öСµÄÇøÓò£¬È»ºóÕë¶ÔÈô¸É¸öСÇøÓò½øÐÐÊý¾Ý´¦Àí¡£
P.S. ÕâÀïÕæÊÇÌå»áµ½ÁËÒ»¸öºÃµÄÃüÃûµÄÁ¦Á¿£¬Group By´Ó×ÖÃæÊÇÖ±½ÓÈ¥Àí½âÊǷdz£ºÃÀí½âµÄ¡£¶÷£¬ÒÔºóÔÚÃü ......
ÁÙʱ±í¾ÍÊÇÄÇЩÃû³ÆÒÔ¾®ºÅ (#) ¿ªÍ·µÄ±í¡£Èç¹ûµ±Óû§¶Ï¿ªÁ¬½ÓʱûÓгýÈ¥ÁÙʱ±í£¬SQL Server ½«×Ô¶¯³ýÈ¥ÁÙʱ±í¡£ÁÙʱ±í²»´æ´¢ÔÚµ±Ç°Êý¾Ý¿âÄÚ£¬¶øÊÇ´æ´¢ÔÚϵͳÊý¾Ý¿â tempdb ÄÚ¡£
ÁÙʱ±íÓÐÁ½ÖÖÀàÐÍ£º
±¾µØÁÙʱ±í
ÒÔÒ»¸ö¾®ºÅ (#) ¿ªÍ·µÄÄÇЩ±íÃû¡£Ö»ÓÐÔÚ´´½¨±¾µØÁÙʱ±íµÄÁ¬½ÓÉϲÅÄÜ¿´µ½ÕâЩ±í£¬Á´½Ó¶Ï¿ªÊ±ÁÙʱ±í¼´±»É¾³ý ......
ÔÚдsqlÓï¾äʱ£¬Ò»°ã¶¼ÊÇÒ»¾ä½â¾ö£¬´ÓÀ´Ã»Ïë¹ý˵£¬°ÑsqlÓï¾ä²ð¿ªÀ´Ð´¡£
ÀýÈçÏÂÃæÕâ¾ä£º string readstring = "select * from ʵÀý where ʵÀýID='"+eid+"'";
È»ºóÖ´ÐÐ Myconnection();
DataSet ds = new DataSet();
OleD ......