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

ÈçºÎÖ´ÐÐÓÃ×Ö·û´®×é³ÉµÄSQLÓï¾ä

 ÔÚ´æ´¢¹ý³ÌÖо­³£ÐèÒªÖ´ÐгÌÐò×é³ÉµÄSQLÓï¾ä£¬¿ÉÒÔʹÓÃexec(@sql),
Ò²¿ÉÒÔʹÓÃexec sp_executesql @sql¡£µ«Ê¹ÓÃsp_executesqlÒªÓÅÓÚexec£¬½¨ÒéʹÓà sp_executesql ¶ø²»ÒªÊ¹Óà EXECUTE Óï¾äÖ´ÐÐ×Ö·û´®¡£Ö§³Ö²ÎÊýÌæ»»²»½öʹ sp_executesql ±È EXECUTE ¸üͨÓ㬶øÇÒ    »¹Ê¹ sp_executesql ¸üÓÐЧ£¬ÒòΪËüÉú³ÉµÄÖ´Ðмƻ®¸üÓпÉÄܱ» SQL Server ÖØÐÂʹÓá£
    µ«Èç¹ûʹÓÃsp_executesql £¬È«¾Ö±äÁ¿±ÈÈç@@rowcount½«Ã»ÓÐÕýÈ·Öµ£¬¶øexecÓУ¬Èç¹ûÏë·µ»Ø¸ÃSQLÖÐijһ×ֶεÄÖµ¿ÉʹÓÃËûµÄ²ÎÊý£¬ÀýÈ磺
@sql='select @id=id from table'
exec sp_executesql @sql N'@id int out ',@id out
print @id


Ïà¹ØÎĵµ£º

ÈçºÎÓÐЧµÄ·ÀÖ¹SQLÁ¬½Ó×Ö·û´®×¢Èë

 ¸ÅÄÔÚ±àд°²È«´úÂëʱ£¬×îÖØÒªµÄ¹æÔòÖ®Ò»¾ÍÊÇ“¾ø¶Ô²»ÒªÃ¤Ä¿µÄÏàÐÅÓû§µÄÊäÈ딡£
ÀûÓÃADO.NET 2.0µÄSqlConnectionStringBuilderÀàÉú³ÉÊý¾Ý¿âÁ¬½Ó×Ö·û´®£¬Ëü¿ÉÒÔÓÐЧµÄ·ÀÖ¹“SQLÁ¬½Ó×Ö·û´®¶ñÒâ×¢È딣¬ÒòΪÕâ¸öÀàÊÇרÃÅΪSQL SERVERÉè¼ÆµÄËùÒÔ£»Ëü¼æÈݾÉʽ¹Ø¼ü×Ö¡£¹ØÓÚÈçºÎʹÓÃSqlConnectionS ......

HibernateµÄÔ­ÉúSQL²éѯ

 ÕÛÌÚÁËÎÒ°ëÌìÖÕÓڸ㶨ÁË
²Î¿¼ÁËÕâ¸öÎÄÕ£ºhttp://doc.javanb.com/hibernate-reference-3-2-0-zh/ch16.html
final static String querySql = "select {enterprise.*}, {dict.*} ,{balancd.*}, {weightinfo.*}  "
   + "from weight_info weightinfo left outer join t_dict dict on {weightinf ......

ÓÃÒ»¾äSQLÈ¡³öµÚ m Ìõµ½µÚ n Ìõ¼Ç¼µÄ·½·¨

 1 --´ÓTable ±íÖÐÈ¡³öµÚ m Ìõµ½µÚ n ÌõµÄ¼Ç¼£º(Not In °æ±¾)
 2
 3 SELECT TOP n-m+1 *
 4 from Table
 5 WHERE (id NOT IN (SELECT TOP m-1 id from Table )) 
 6
 7
 8 --´ÓTABLE±íÖÐÈ¡³öµÚmµ½nÌõ¼Ç¼ (Exists°æ±¾)
 9
10 SELECT TOP n-m+1 * from ......

sql±¸Íü¼

SELECT --´ÓÊý¾Ý¿â±íÖмìË÷Êý¾ÝÐкÍÁÐ
INSERT --ÏòÊý¾Ý¿â±íÌí¼ÓÐÂÊý¾ÝÐÐ
DELETE --´ÓÊý¾Ý¿â±íÖÐɾ³ýÊý¾ÝÐÐ
UPDATE --¸üÐÂÊý¾Ý¿â±íÖеÄÊý¾Ý
--SQLÊý¾Ý¶¨Òå
CREATE TABLE --´´½¨Ò»¸öÊý¾Ý¿â±í
DROP TABLE --´ÓÊý¾Ý¿âÖÐɾ³ý±í
ALTER TABLE --ÐÞ¸ÄÊý¾Ý¿â±í½á¹¹
CREATE VIEW --´´½¨Ò»¸öÊÓͼ
DROP VIEW --´ÓÊý¾Ý¿âÖÐɾ³ýÊ ......

SQL ServerÊý¾Ý¿â±¸·ÝºÍ»Ö¸´´ëÊ©

 ¡¡Ò»¡¢±¸·ÝÊý¾Ý¿â
¡¡¡¡1¡¢´ò¿ªSQLÆóÒµ¹ÜÀíÆ÷£¬ÔÚ¿ØÖÆ̨¸ùĿ¼ÖÐÒÀ´Îµã¿ªMicrosoft SQL Server
¡¡¡¡2¡¢SQL Server×é-->Ë«»÷´ò¿ªÄãµÄ·þÎñÆ÷-->Ë«»÷´ò¿ªÊý¾Ý¿âĿ¼
¡¡¡¡3¡¢Ñ¡ÔñÄãµÄÊý¾Ý¿âÃû³Æ£¨ÈçÂÛ̳Êý¾Ý¿âForum£©-->È»ºóµãÉÏÃæ²Ëµ¥ÖеŤ¾ß-->Ñ¡Ôñ±¸·ÝÊý¾Ý¿â
¡¡¡¡4¡¢±¸·ÝÑ¡ÏîÑ¡ÔñÍêÈ«±¸·Ý£¬Ä¿µÄÖеı ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ