SQL Server Êý¾Ý¿â¹ÊÕÏÐÞ¸´¶¥¼¶¼¼ÇÉÖ®Ò» ת
SQL Server Êý¾Ý¿â¹ÊÕÏÐÞ¸´¶¥¼¶¼¼ÇÉÖ®Ò»
2010-04-26 10:37:52 À´Ô´:TechTargetÖйú ÎÒÒªÊÕ²Ø
SQL Server 2005 ºÍ 2008 Óм¸¸ö¹ØÓڸ߿ÉÓÃÐÔµÄÑ¡ÏÈçÈÕÖ¾´«Êä¡¢¸±±¾ºÍÊý¾Ý¿â¾µÏñ¡£ËùÓÐÕâЩ¼¼Êõ¶¼Äܹ»×÷Ϊά»¤Ò»¸ö±¸Ó÷þÎñÆ÷µÄÊֶΣ¬Í¬Ê±Õâ¸öÊý¾Ý¿â¿ÉÒÔÔÚÄãÔÏȵÄÖ÷Êý¾Ý¿â³öÎÊÌâʱÉÏÏß²¢×÷ΪеÄÖ÷·þÎñÆ÷¡£È»¶ø£¬Äã±ØÐë¼ÇסµÄÊǽ«±¸Ó÷þÎñÆ÷Ìæ»»ÉÏÏßÖ»ÊÇÍê³ÉÁËÒ»°ëµÄ¹ÊÕÏÐÞ¸´¹¤×÷¡£
Òª±£Ö¤ÄãµÄÓ¦ÓÃÕý³£¹¤×÷£¬ÔÚÊý¾Ý¿âÍⲿ»¹ÓÐÐí¶à×¢ÒâÊÂÏî¡£ÕâÆäÖаüÀ¨µÇ¼ÐÅÏ¢¡¢Êý¾Ý¿âÓû§¡¢µ÷¶ÈÈÎÎñ¡¢DTS ºÍ SSIS °ü¡¢¿ÉÖ´ÐÐÎļþ¡¢ÏµÍ³Êý¾Ý¿âÖеĶÔÏó¡¢Í¬ÃûÊý¾Ý¿â¡¢Á´½Ó·þÎñÆ÷µÈµÈ¡£
ÓÐʱÕâЩϸСµÄÒÀÀµÖ»ÓÐÔÚÄã½øÐÐÒ»¸öÊý¾Ý¿â¹ÊÕϻָ´Ê±²Å»á·¢ÏÖ£¬ÕâÑùÄãÓÖ²»µÃ²»»¨·Ñ´óÁ¿Ê±¼ä½øÐе÷ÊÔºÍÆÀ¹Àµ¼ÖÂÕâ¸öÎÊÌâµÄ¸ùÔ´¡£´ËÍ⣬Ä㻹±ØÐëÈõڶþ̨·þÎñÆ÷ºÍÓ¦Óþ¡¿ÉÄÜ¿ìµØÉÏÏßÒÔ¼õÉÙÍ£»úʱ¼ä¡£Òò´Ë£¬ÌáÇ°×öÉèÖÃÊǷdz£ÖØÒªµÄ¡£
µ±Éæ¼°µ½¸ß¿ÉÓÃÐÔºÍSQL Server µÄÔÖÄѻָ´¹æ»®Ê±£¬ÄãÓ¦¸Ã½÷¼ÇÎÒ±¾ÈËËùϲ»¶µÄÒ»¸öÀ¶¡ÑèÓï ——Si vis pacem, para bellum£¬ËüµÄÒâ˼·Òë¹ýÀ´¾ÍÊÇ“Èç¹ûÄãÏëÒªµÃµ½ºÍƽ£¬ÄǾ͵ÃÏÈ×÷ºÃÕ½Õù×¼±¸¡£”¼ÇסÕâÒ»µãºó£¬ÈÃÎÒÃÇÀ´¿´¿´Ò»Ð©¿ÉÄÜ»áÓöµ½µÄÎÊÌâ¡£ÎÒÒ²½«½¨Ò鼸¸öÔ¤ÏÈ¿ÉÒÔÍê³ÉµÄÈÎÎñ£¬ÒÔÈ·±£Êý¾Ý¿â¹ÊÕϻָ´¹ý³Ì¿ìËÙÓÐЧµØÍê³É¡£
SQL Server µÇ¼ÐÅÏ¢ÓëÊý¾Ý¿âÓû§
ÄãµÄ¹ÊÕϻָ´·þÎñÆ÷Ó¦¸Ã±¸·ÝËùÓеĵǼÐÅÏ¢ºÍÊý¾Ý¿âÓû§£¬°üÀ¨ÃÜÂë¡£µÇ¼ÐÅÏ¢¿ÉÒÔÔÚÈκÎʱºò´´½¨£¬µ«ÊÇÈç¹ûÄãʹÓÃÈÕÖ¾´«Êä»òÊý¾Ý¿â¾µÏñ£¬ÄãµÄÊý¾Ý¿â½«´¦Àí»Ö¸´×´Ì¬£¬ÕâÑùÄãÖ»ÓÐÔÚËüÃÇÖØÐÂÉÏÏߺó²ÅÄÜÍê³É»Ö¸´¹ý³Ì¡£
ʹÓà Windows ÈÏÖ¤£¬¿ÉÒÔºÜÈÝÒ׵ؽ«µÇ¼ÐÅÏ¢Ó³Éäµ½Êý¾Ý¿âÓû§¡£È»¶ø£¬Èç¹ûÄãʹÓõÄÊÇ SQL ÈÏÖ¤£¬ÄÇôÄãÐèÒªÊÖ¶¯µØÔÚÄã´ÓÁíÒ»¸ö·þÎñÆ÷»ñµÃµÄÊý¾Ý¿âÉÏÖØн¨Á¢µÇ¼ÐÅÏ¢ÓëÊý¾Ý¿âÓû§µÄÁ¬½Ó¡£Òò´Ë£¬ÄãÔÚǨÒÆÊý¾Ý¿âʱ»á¶ªÊ§µÇ¼ÐÅÏ¢ºÍÊý¾Ý¿âÓû§Ö®¼äµÄÁ¬½Ó¡£
µ±ÄãÔÚµÚ¶þ̨·þÎñÆ÷Éϻָ´Êý¾Ý¿âºó£¬ÔËÐÐÕâЩ´úÂ룺
USE YourDatabaseName
EXEC sp_change_Users_Login 'UPDATE_ONE', YourDBUserName, YourLogin
±£³ÖµÇ¼ÐÅϢͬ²½µÄÁíÒ»¸ö·½·¨ÊÇ×ñÑ Microsoft Knowledge Base ÉϹØÓÚ ÔÚ SQL Server ʵÀýÖ®¼ä´«ÊäµÇ¼ÐÅÏ¢ºÍÃÜÂë µÄÎÄÕµIJ½Öè¡£ÕâƪÎÄÕ²ûÊöÁËÈçºÎʹÓÃÔʼµÄ SID ½Å±¾»¯µÇ¼ÐÅÏ¢¡£µ±ÔÚ¹ÊÕϻָ´Êý¾Ý¿â·þÎñÆ÷ÉÏ´´½¨ÕâЩµÇ¼ÐÅϢʱ£¬µÇ¼ÐÅÏ¢ÓëÊý¾Ý¿âÓû§Ö®¼äµÄÁ¬½Ó»á±»±£´æ£¬ÕâÑùÄã¾Í²»±ØÔËÐÐÉÏÃæµÄ½Å±¾ÐÞ¸´¹ÂÁ¢µÄÓû§¡£
Ïà¹ØÎĵµ£º
Êý¾Ý¿â²Ù×÷Àࣺ
¸´ÖÆ´úÂë ´úÂëÈçÏÂ:
/// <summary>
/// È¡µÃ×ÜÊý
/// </summary>
/// <returns></returns>
public string getTotal()
{
StringBuilder sb = new StringBuilder();
sb.Append("select count(*) total from Test");
DataTable dt = DBHelper.ExecuteDt(sb.ToString ......
--SQL Server 2008 ¶¨Ê±×÷ÒµµÄÖƶ¨
--1.´ò¿ª¡¾SQL Server Management Studio¡¿£¬ÔÚ¡¾¶ÔÏó×ÊÔ´¹ÜÀíÆ÷¡¿ÁбíÖÐÑ¡Ôñ¡¾SQL Server ´úÀí¡¿£»
--2.Êó±êÓÒ»÷¡¾SQL Server ´úÀí¡¿£¬Ñ¡Ôñ¡¾Æô¶¯(S)¡¿£¬ÈçÒÑÆô¶¯£¬¿ÉÒÔÊ¡ÂԴ˲½Ö裻
--3.Õ¹¿ª¡¾SQL Server ´úÀí¡¿ÁÐ±í£¬ÓÒ»÷¡¾×÷Òµ¡¿-->¡¾Ð½¨×÷Òµ¡¿£»
--3.1 ÔÚ¡¾³£¹æ¡¿Ñ¡Ïî ......
ÊÓͼÊÇ¿ÉÊÓ»¯µÄ±í¡£
±¾Õ½²½âÈçºÎ´´½¨¡¢¸üкÍɾ³ýÊÓͼ¡£
SQL CREATE VIEW Óï¾ä
ʲôÊÇÊÓͼ£¿
ÔÚ SQL ÖУ¬ÊÓͼÊÇ»ùÓÚ SQL Óï¾äµÄ½á¹û¼¯µÄ¿ÉÊÓ»¯µÄ±í¡£
ÊÓͼ°üº¬ÐкÍÁУ¬¾ÍÏñÒ»¸öÕæʵµÄ±í¡£ÊÓͼÖеÄ×ֶξÍÊÇÀ´×ÔÒ»¸ö»ò¶à¸öÊý¾Ý¿âÖеÄÕæʵµÄ±íÖеÄ×ֶΡ£ÎÒÃÇ¿ÉÒÔÏòÊÓͼÌí¼Ó SQL º¯Êý¡¢WHERE ÒÔ¼° JOIN Óï¾ä£¬ÎÒÃÇÒ²¿ÉÒ ......
1¡¢join
A±íµÄÖ÷¼üÊÇ×÷ΪB±íµÄÍâ¼ü¡£ÔÚ²éѯµÄʱºò£¬¿ÉÒÔͨ¹ý²»Í¬µÄjoin½«AºÍB±íÁ´½ÓÆðÀ´£¬´Ó¶øµÃµ½²»Í¬µÄ²éѯ½á¹û¡£
* JOIN: Èç¹û±íÖÐÓÐÖÁÉÙÒ»¸öÆ¥Å䣬Ôò·µ»ØÐÐ
* INNER JOIN: Èç¹ûÁ½¸ö±íÖÐÓÐÆ¥ÅäµÄ£¬Ôò·µ»ØÐÐ
* LEFT JOIN: ¼´Ê¹ÓÒ±íÖÐûÓÐÆ¥Å䣬Ҳ´Ó×ó± ......
ÔÚ¹¤×÷ÖÐÓöµ½Ò»¸öÎÊÌâ,ÊÇÐèÒªsqlµÝ¹é²éѯµÄ.²»¶®,ÓÚÊǵ½csdnÉÏÈ¥ÎÊ,ÄÇÀïµÄЧÂÊÕæÊǷdz£¸ß,ÎÒÒÔǰҲûÔÚÉÏÃæÎʹýÎÊÌâ.
ÎÊÌâÃèÊö:
ÎÒÓÐÒ»¸ö±í½á¹¹ÈçÏÂ:
id upperid
1 2
3 2
4 1
5 3
¾ßÌå²ã´Î²»ÖªµÀ,ÎÒÏëÓõݹésqlÓ ......