sql server 2000 È«ÎÄË÷ÒýÈ«½â
http://hi.baidu.com/dumao/blog/item/1cafa71e5886d019413417e4.html
1.È«ÎÄË÷Òý¸ÅÊö
¶Ô Microsoft® SQL Server™ 2000 Êý¾ÝµÄÈ«ÎÄÖ§³ÖÉæ¼°Á½¸ö¹¦ÄÜ£º¶Ô×Ö·ûÊý¾Ý·¢³ö²éѯµÄÄÜÁ¦ºÍ´´½¨¼°Î¬»¤»ù´¡Ë÷ÒýÒÔ¼ò»¯ÕâЩ²éѯµÄÄÜÁ¦¡£
È«ÎÄË÷ÒýÔÚÐí¶àµØ·½ÓëÆÕͨµÄ SQL Ë÷Òý²»Í¬¡£
ÆÕͨ SQL Ë÷ÒýÈ«ÎÄË÷Òý
´æ´¢Ê±Êܶ¨ÒåËüÃÇËùÔÚµÄÊý¾Ý¿âµÄ¿ØÖÆ¡£
´æ´¢ÔÚÎļþϵͳÖУ¬µ«Í¨¹ýÊý¾Ý¿â¹ÜÀí¡£
ÿ¸ö±íÔÊÐíÓÐÈô¸É¸öÆÕͨË÷Òý¡£
ÿ¸ö±íÖ»ÔÊÐíÓÐÒ»¸öÈ«ÎÄË÷Òý¡£
µ±¶Ô×÷ΪÆä»ù´¡µÄÊý¾Ý½øÐвåÈë¡¢¸üлòɾ³ýʱ£¬ËüÃÇ×Ô¶¯¸üС£
½«Êý¾ÝÌí¼Óµ½È«ÎÄË÷Òý³ÆΪÌî³ä£¬È«ÎÄË÷Òý¿Éͨ¹ýµ÷¶È»òÌض¨ÇëÇóÀ´ÇëÇó£¬Ò²¿ÉÒÔÔÚÌí¼ÓÐÂÊý¾Ýʱ×Ô¶¯·¢Éú¡£
²»·Ö×é¡£
ÔÚͬһ¸öÊý¾Ý¿âÄÚ·Ö×éΪһ¸ö»ò¶à¸öÈ«ÎÄĿ¼¡£
ʹÓà SQL Server ÆóÒµ¹ÜÀíÆ÷¡¢Ïòµ¼»ò Transact-SQL Óï¾ä´´½¨ºÍ³ýÈ¥¡£
ʹÓà SQL Server ÆóÒµ¹ÜÀíÆ÷¡¢Ïòµ¼»ò´æ´¢¹ý³Ì´´½¨¡¢¹ÜÀíºÍ³ýÈ¥¡£
ÕâЩ²îÒìʹ´óÁ¿¹ÜÀíÈÎÎñ±äµÃ²»¿ÉȱÉÙ¡£È«ÎĹÜÀíÊÇÔÚ¼¸¸ö²ã´ÎÉÏʵʩµÄ£º
·þÎñÆ÷
¿ÉÒÔ¶Ô·þÎñÆ÷·¶Î§µÄijЩÊôÐÔ£¨Èç resource_usage£©¼ÓÒÔÉèÖã¬ÒÔ±ãÔö¼Ó»ò¼õÉÙÈ«ÎÄ·þÎñËùʹÓõÄϵͳ×ÊÔ´ÊýÁ¿¡£
˵Ã÷ È«ÎÄÒýÇæ×÷ΪÃûΪ Microsoft ËÑË÷µÄ·þÎñÔÚ Microsoft Windows NT® Server ºÍ Microsoft Windows® 2000 Server ÉÏÔËÐС£¶ÔÓÚ Microsoft SQL Server ¸öÈ˰棬Microsoft ËÑË÷·þÎñ²»¿ÉÓ᣾¡¹ÜÕâÒâζ×Å Microsoft ËÑË÷·þÎñ¼Èδ°²×°ÔÚ Microsoft Windows 95/98 ÉÏ£¬Ò²Î´°²×°ÔÚ Windows NT ¹¤×÷Õ¾»ò Windows 2000 Professional ¿Í»§¶ËÉÏ£¬µ«ÕâЩ¿Í»§¶ËÔÚÁ¬½Óµ½ SQL Server ±ê×¼°æ°²×°»òÆóÒµ°æʵÀýʱ¿ÉÒÔʹÓÃÕâÏî·þÎñ¡£
Êý¾Ý¿â
±ØÐëÆôÓÃÊý¾Ý¿â²ÅÄÜʹÓÃÈ«ÎÄ·þÎñ¡£¿ÉÒÔÔÚÒÑÆôÓõÄÊý¾Ý¿âÖд´½¨ºÍ³ýÈ¥Ò»¸ö»ò¶à¸öÈ«ÎÄĿ¼µÄÔªÊý¾Ý¡£
È«ÎÄĿ¼
È«ÎÄĿ¼°üº¬Êý¾Ý¿âÖеÄÈ«ÎÄË÷Òý¡£Ã¿¸öĿ¼¿ÉÒÔÓÃÓÚÊý¾Ý¿âÄÚµÄÒ»¸ö»ò¶à¸ö±íµÄË÷ÒýÐèÇ󡣸ÃĿ¼ÖеÄË÷ÒýÊÇʹÓÃÕâÀï½éÉܵĹÜÀí¹¦ÄÜÀ´Ìî³äµÄ¡££¨È«ÎÄĿ¼±ØÐëפÁôÔÚÓë SQL Server ʵÀýÏà¹ØÁªµÄ±¾µØÓ²ÅÌÇý¶¯Æ÷ÉÏ¡£²»Ö§³Ö¿ÉÒƶ¯µÄÇý¶¯Æ÷¡¢ÈíÅ̺ÍÍøÂçÇý¶¯Æ÷£©¡£ÔÚÿ¸ö·þÎñÆ÷ÉÏ×î¶à¿É´´½¨ 256 ¸öÈ«ÎÄĿ¼¡£
˵Ã÷ Windows NT ¹ÊÕÏתÒÆȺ¼¯»·¾³ÍêÈ«Ö§³ÖÈ«ÎÄË÷Òý¡£Óйظü¶àÐÅÏ¢£¬Çë²Î¼ûÔÚ¹ÊÕÏתÒÆȺ¼¯ÖÐÔËÐÐÈ«ÎIJéѯ¡£
±í
Ê×ÏÈ£¬±ØÐëΪȫÎÄÖ§³ÖÆôÓÃ±í¡£È»ºó£¬ÎªÓë¸Ã±íÏà¹ØÁªµÄÈ«ÎÄË÷Òý´´½¨ÔªÊý¾Ý£¨Èç±íÃû¼°ÆäÈ«ÎÄĿ¼£©¡£±íÆôÓú󣬿ÉÒÔÓÃΪȫÎÄÖ§³Ö¶
Ïà¹ØÎĵµ£º
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
¡¡¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢ËµÃ÷£º´´½¨Êý ......
ÔÚSQL ServerÀï²é¿´µ±Ç°Á¬½ÓµÄÔÚÏßÓû§Êý
use master
select loginame,count(0) from sysprocesses
group by loginame
order by count(0) desc
select nt_username,count(0) from sysprocesses
group by nt_username
order by count(0) desc
Èç¹ûij¸öSQL ServerÓû§ÃûtestÁ¬½Ó±È½Ï¶à,²é¿´ËüÀ´×ÔµÄÖ÷»úÃû:
......
1¡¢¹«Óñí±í´ïʽ (CTE) ¿ÉÒÔÈÏΪÊÇÔÚµ¥¸ö SELECT¡¢INSERT¡¢UPDATE¡¢DELETE »ò CREATE VIEW Óï¾äµÄÖ´Ðз¶Î§ÄÚ¶¨ÒåµÄÁÙʱ½á¹û¼¯¡£CTE ÓëÅÉÉú±íÀàËÆ£¬¾ßÌå±íÏÖÔÚ²»´æ´¢Îª¶ÔÏ󣬲¢ÇÒÖ»ÔÚ²éѯÆÚ¼äÓÐЧ¡£ÓëÅÉÉú±íµÄ²»Í¬Ö®´¦ÔÚÓÚ£¬CTE ¿É×ÔÒýÓ㬻¹¿ÉÔÚͬһ²éѯÖÐÒýÓöà´Î¡£
¡¡¡¡CTE ¿ÉÓÃÓÚ£º
¡¡¡¡´´½¨µÝ¹é²éѯ¡£ÓйØÏêϸР......
ÏÂÃæÊÇÎÒËѼ¯µÄһЩ¾«ÃîµÄSQLÓï¾ä¡£
˵Ã÷£º¸´ÖƱí(Ö»¸´Öƽṹ,Ô´±íÃû£ºa бíÃû£ºb)
SQL: select * into b from a where 1<>1
˵Ã÷£º¿½±´±í(¿½±´Êý¾Ý,Ô´±íÃû£ºa Ä¿±ê±íÃû£ºb)
SQL: insert into b(a, b, c) select d,e,f from b;
˵Ã÷£ºÏÔʾÎÄÕ¡¢Ìá½»È˺Í×îºó»Ø¸´Ê±¼ä
SQL: select a.title,a.username,b.adddat ......
½«ExcelÎļþÊý¾Ý¿âµ¼ÈëSQL ServerµÄÈýÖÖ·½°¸
//·½°¸Ò»£º ͨ¹ýOleDB·½Ê½»ñÈ¡ExcelÎļþµÄÊý¾Ý£¬È»ºóͨ¹ýDataSetÖÐתµ½SQL Server
openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Excel files(*.xls)|*.xls";
if(openFileDialog.ShowDialog()==DialogResult.OK)
{
FileInfo ......