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

SQL Server Ë÷Òý½á¹¹¼°ÆäʹÓ㨶þ£©

SQL Server Ë÷Òý½á¹¹¼°ÆäʹÓ㨶þ£©
×÷Õߣºfreedk
Ò»¡¢ÉîÈëdz³öÀí½âË÷Òý½á¹¹
¸ÄÉÆSQLÓï¾ä
¡¡¡¡ºÜ¶àÈ˲»ÖªµÀSQLÓï¾äÔÚSQL SERVERÖÐÊÇÈçºÎÖ´Ðеģ¬ËûÃǵ£ÐÄ×Ô¼ºËùдµÄSQLÓï¾ä»á±»SQL SERVERÎó½â¡£±ÈÈ磺
select * from table1 where name=''zhangsan'' and tID > 10000
ºÍÖ´ÐÐ:
select * from table1 where tID > 10000 and name=''zhangsan''
¡¡¡¡Ò»Ð©È˲»ÖªµÀÒÔÉÏÁ½ÌõÓï¾äµÄÖ´ÐÐЧÂÊÊÇ·ñÒ»Ñù£¬ÒòΪÈç¹û¼òµ¥µÄ´ÓÓï¾äÏȺóÉÏ¿´£¬ÕâÁ½¸öÓï¾äµÄÈ·ÊDz»Ò»Ñù£¬Èç¹ûtIDÊÇÒ»¸ö¾ÛºÏË÷Òý£¬ÄÇôºóÒ»¾ä½ö½ö´Ó±íµÄ10000ÌõÒÔºóµÄ¼Ç¼ÖвéÕÒ¾ÍÐÐÁË£»¶øÇ°Ò»¾äÔòÒªÏÈ´ÓÈ«±íÖвéÕÒ¿´Óм¸¸öname=''zhangsan''µÄ£¬¶øºóÔÙ¸ù¾ÝÏÞÖÆÌõ¼þÌõ¼þtID>10000À´Ìá³ö²éѯ½á¹û¡£
¡¡¡¡ÊÂʵÉÏ£¬ÕâÑùµÄµ£ÐÄÊDz»±ØÒªµÄ¡£SQL SERVERÖÐÓÐÒ»¸ö“²éѯ·ÖÎöÓÅ»¯Æ÷”£¬Ëü¿ÉÒÔ¼ÆËã³öwhere×Ó¾äÖеÄËÑË÷Ìõ¼þ²¢È·¶¨ÄĸöË÷ÒýÄÜËõС±íɨÃèµÄËÑË÷¿Õ¼ä£¬Ò²¾ÍÊÇ˵£¬ËüÄÜʵÏÖ×Ô¶¯ÓÅ»¯¡£
¡¡¡¡ËäÈ»²éѯÓÅ»¯Æ÷¿ÉÒÔ¸ù¾Ýwhere×Ó¾ä×Ô¶¯µÄ½øÐвéѯÓÅ»¯£¬µ«´ó¼ÒÈÔÈ»ÓбØÒªÁ˽âһϓ²éѯÓÅ»¯Æ÷”µÄ¹¤×÷Ô­Àí£¬Èç·ÇÕâÑù£¬ÓÐʱ²éѯÓÅ»¯Æ÷¾Í»á²»°´ÕÕÄúµÄ±¾Òâ½øÐпìËÙ²éѯ¡£
¡¡¡¡ÔÚ²éѯ·ÖÎö½×¶Î£¬²éѯÓÅ»¯Æ÷²é¿´²éѯµÄÿ¸ö½×¶Î²¢¾ö¶¨ÏÞÖÆÐèҪɨÃèµÄÊý¾ÝÁ¿ÊÇ·ñÓÐÓá£Èç¹ûÒ»¸ö½×¶Î¿ÉÒÔ±»ÓÃ×÷Ò»¸öɨÃè²ÎÊý£¨SARG£©£¬ÄÇô¾Í³Æ֮Ϊ¿ÉÓÅ»¯µÄ£¬²¢ÇÒ¿ÉÒÔÀûÓÃË÷Òý¿ìËÙ»ñµÃËùÐèÊý¾Ý¡£
¡¡¡¡SARGµÄ¶¨Ò壺ÓÃÓÚÏÞÖÆËÑË÷µÄÒ»¸ö²Ù×÷£¬ÒòΪËüͨ³£ÊÇÖ¸Ò»¸öÌض¨µÄÆ¥Å䣬һ¸öÖµµÃ·¶Î§ÄÚµÄÆ¥Åä»òÕßÁ½¸öÒÔÉÏÌõ¼þµÄANDÁ¬½Ó¡£ÐÎʽÈçÏ£º
ÁÐÃû ²Ù×÷·û <³£Êý »ò ±äÁ¿>
»ò
<³£Êý »ò ±äÁ¿> ²Ù×÷·ûÁÐÃû
ÁÐÃû¿ÉÒÔ³öÏÖÔÚ²Ù×÷·ûµÄÒ»±ß£¬¶ø³£Êý»ò±äÁ¿³öÏÖÔÚ²Ù×÷·ûµÄÁíÒ»±ß¡£È磺
Name=’ÕÅÈý’
¼Û¸ñ>5000
5000<¼Û¸ñ
Name=’ÕÅÈý’ and ¼Û¸ñ>5000
¡¡¡¡Èç¹ûÒ»¸ö±í´ïʽ²»ÄÜÂú×ãSARGµÄÐÎʽ£¬ÄÇËü¾ÍÎÞ·¨ÏÞÖÆËÑË÷µÄ·¶Î§ÁË£¬Ò²¾ÍÊÇSQL SERVER±ØÐë¶ÔÿһÐж¼ÅжÏËüÊÇ·ñÂú×ãWHERE×Ó¾äÖеÄËùÓÐÌõ¼þ¡£ËùÒÔÒ»¸öË÷Òý¶ÔÓÚ²»Âú×ãSARGÐÎʽµÄ±í´ïʽÀ´ËµÊÇÎÞÓõġ£
¡¡¡¡½éÉÜÍêSARGºó£¬ÎÒÃÇÀ´×ܽáÒ»ÏÂʹÓÃSARGÒÔ¼°ÔÚʵ¼ùÖÐÓöµ½µÄºÍijЩ×ÊÁÏÉϽáÂÛ²»Í¬µÄ¾­Ñ飺
1¡¢LikeÓï¾äÊÇ·ñÊôÓÚSARGÈ¡¾öÓÚËùʹÓõÄͨÅä·ûµÄÀàÐÍ
È磺name like ‘ÕÅ%’ £¬Õâ¾ÍÊôÓÚSARG
¶ø£ºname like ‘%ÕÅ’ ,¾Í²»ÊôÓÚSARG¡£
Ô­ÒòÊÇͨÅä·û%ÔÚ×Ö·û´®µÄ¿ªÍ¨Ê¹µÃË÷ÒýÎÞ·¨Ê¹Óá£
2¡¢or »áÒýÆ


Ïà¹ØÎĵµ£º

SQL UnionºÍUnion AllµÄʹÓ÷½·¨

¡¡UNIONÖ¸ÁîµÄÄ¿µÄÊǽ«Á½¸öSQLÓï¾äµÄ½á¹ûºÏ²¢ÆðÀ´¡£´ÓÕâ¸ö½Ç¶ÈÀ´¿´£¬ ÎÒÃÇ»á²úÉúÕâÑùµÄ¸Ð¾õ£¬UNION¸úJOINËƺõÓÐЩÐíÀàËÆ£¬ÒòΪÕâÁ½¸öÖ¸Á¿ÉÒÔÓɶà¸ö±í¸ñÖÐߢȡ×ÊÁÏ¡£ UNIONµÄÒ»¸öÏÞÖÆÊÇÁ½¸ö SQL Óï¾äËù²úÉúµÄÀ¸Î»ÐèÒªÊÇͬÑùµÄ×ÊÁÏÖÖÀà¡£ÁíÍ⣬µ±ÎÒÃÇÓà UNIONÕâ¸öÖ¸Áîʱ£¬ÎÒÃÇÖ»»á¿´µ½²»Í¬µÄ×ÊÁÏÖµ (ÀàËÆ SELECT DISTINCT) ......

±¸·ÝºÍ»¹Ô­SQL Server¼°Ñ¹ËõAccessÊý¾Ý¿â

*
 * ¹¦ÄÜ˵Ã÷:±¸·ÝºÍ»Ö¸´SQL ServerÊý¾Ý¿â
 * ×÷Õß: Áõ¹¦Ñ«;
 * °æ±¾:V0.1(C#2.0);ʱ¼ä:2007-1-1
 * µ±Ê¹ÓÃSQL Serverʱ,ÇëÒýÓà COM×é¼þÖеÄ,SQLDMO.dll×é¼þ
 * µ±Ê¹ÓÃAccessÖÐ,Çëä¯ÀÀÌí¼ÓÒýÓÃÒÔÏÂÁ½¸ödll
 *          ÒýÓÃC:/Progra ......

ÓÃIP·ÃÎÊSQL Server 2008

1¡¢¿ªÊ¼->³ÌÐò-->Microsoft SQL Server 2005>ÅäÖù¤¾ß->SQL Server Configuration Manager->SQL Server 2005 ÍøÂçÅäÖà ->“xxx£¨ÄúµÄÊý¾Ý¿â£©”µÄЭÒ飬ÈçÏÂͼ
½«“Named Pipes”ºÍ“TCP/IP”µÄ״̬µ÷³É“ÆôÓÔ£¬·½·¨ÊÇÔÚ“Named Pipes”ºÍ“T ......

C#Á¬½ÓACESSʱ£¬sqlÓï¾äÓдí

ÔÚдsqlÓï¾äʱ£¬Ò»°ã¶¼ÊÇÒ»¾ä½â¾ö£¬´ÓÀ´Ã»Ïë¹ý˵£¬°ÑsqlÓï¾ä²ð¿ªÀ´Ð´¡£
ÀýÈçÏÂÃæÕâ¾ä£º  string readstring = "select * from ʵÀý where ʵÀýID='"+eid+"'";
È»ºóÖ´ÐÐ Myconnection();
        DataSet ds = new DataSet();
        OleD ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ