ÈçºÎÖ´ÐÐÓÃ×Ö·û´®×é³ÉµÄ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
Ïà¹ØÎĵµ£º
¸ÅÄÔÚ±àд°²È«´úÂëʱ£¬×îÖØÒªµÄ¹æÔòÖ®Ò»¾ÍÊÇ“¾ø¶Ô²»ÒªÃ¤Ä¿µÄÏàÐÅÓû§µÄÊäÈ딡£
ÀûÓÃADO.NET 2.0µÄSqlConnectionStringBuilderÀàÉú³ÉÊý¾Ý¿âÁ¬½Ó×Ö·û´®£¬Ëü¿ÉÒÔÓÐЧµÄ·ÀÖ¹“SQLÁ¬½Ó×Ö·û´®¶ñÒâ×¢È딣¬ÒòΪÕâ¸öÀàÊÇרÃÅΪSQL SERVERÉè¼ÆµÄËùÒÔ£»Ëü¼æÈݾÉʽ¹Ø¼ü×Ö¡£¹ØÓÚÈçºÎʹÓÃSqlConnectionS ......
ÕÛÌÚÁËÎÒ°ëÌìÖÕÓڸ㶨ÁË
²Î¿¼ÁËÕâ¸öÎÄÕ£º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 ......
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 ......
SELECT --´ÓÊý¾Ý¿â±íÖмìË÷Êý¾ÝÐкÍÁÐ
INSERT --ÏòÊý¾Ý¿â±íÌí¼ÓÐÂÊý¾ÝÐÐ
DELETE --´ÓÊý¾Ý¿â±íÖÐɾ³ýÊý¾ÝÐÐ
UPDATE --¸üÐÂÊý¾Ý¿â±íÖеÄÊý¾Ý
--SQLÊý¾Ý¶¨Òå
CREATE TABLE --´´½¨Ò»¸öÊý¾Ý¿â±í
DROP TABLE --´ÓÊý¾Ý¿âÖÐɾ³ý±í
ALTER TABLE --ÐÞ¸ÄÊý¾Ý¿â±í½á¹¹
CREATE VIEW --´´½¨Ò»¸öÊÓͼ
DROP VIEW --´ÓÊý¾Ý¿âÖÐɾ³ýÊ ......
¡¡Ò»¡¢±¸·ÝÊý¾Ý¿â
¡¡¡¡1¡¢´ò¿ªSQLÆóÒµ¹ÜÀíÆ÷£¬ÔÚ¿ØÖÆ̨¸ùĿ¼ÖÐÒÀ´Îµã¿ªMicrosoft SQL Server
¡¡¡¡2¡¢SQL Server×é-->Ë«»÷´ò¿ªÄãµÄ·þÎñÆ÷-->Ë«»÷´ò¿ªÊý¾Ý¿âĿ¼
¡¡¡¡3¡¢Ñ¡ÔñÄãµÄÊý¾Ý¿âÃû³Æ£¨ÈçÂÛ̳Êý¾Ý¿âForum£©-->È»ºóµãÉÏÃæ²Ëµ¥ÖеŤ¾ß-->Ñ¡Ôñ±¸·ÝÊý¾Ý¿â
¡¡¡¡4¡¢±¸·ÝÑ¡ÏîÑ¡ÔñÍêÈ«±¸·Ý£¬Ä¿µÄÖеı ......