SQL server 2005(´æ´¢¹ý³Ì)
Ò»£®¸ÅÊö
´æ´¢¹ý³ÌÊÇÒ»×éÔ¤ÏȱàÒëºÃµÄT--SQL´úÂ룬ǿµ÷Ò»µã£ºÕâЩ´úÂëÊÇÔ¤±àÒëºÃµÄ£¬¼´ÔÚÖ´ÐÐʱ¾Í²»ÓÃÔÚ½øÐбàÒëÁË£¬ÕâÑù»áÌá¸ß³ÌÐòµÄÔËÐÐЧÂÊ¡£ËüÀàËÆÓÚÆäËû¸ß¼¶ÓïÑÔÀïµÄ¹ý³Ì£¬¼´Íê³ÉÌض¨¹¦Äܵĺ¯Êý¡£´æ´¢¹ý³Ì·ÖÁ½ÀࣺϵͳÌṩµÄ´æ´¢¹ý³Ì£¬Óû§×Ô¼º¶¨ÒåµÄ´æ´¢¹ý³Ì£¬ÏµÍ³¶¨ÒåµÄÒÔ sp_Ϊǰ׺¡£
¶þ£®´æ´¢¹ý³Ì
1.Á½ÖÖ·½·¨´´½¨´æ´¢¹ý³Ì£º
(1).ͨ¹ýCREATE PROCEDUREÃüÁî´´½¨
¸ñʽ£º
CREATE PROCEDURE <¹ý³ÌÃû>
AS T--SQLÓï¾ä
Ò»¸ö´æ´¢¹ý³ÌµÄ×î´ó³ß´çΪ128M£¬Óû§µÄ´æ´¢¹ý³Ì±ØÐ뽨Á¢ÔÚµ±Ç°Êý¾Ý¿âÀï¡£½¨Á¢´æ´¢¹ý³ÌÊ×ÏȵÃÏÈɾ³ýÔÓеĴ洢¹ý³Ì£¬ÔÙ´´½¨Í¬ÃûµÄ´æ´¢¹ý³Ì¡£
(2).ÔËÓÃÆóÒµ¹ÜÀíÆ÷´´½¨¡£
2.¹ÜÀí´æ´¢¹ý³Ì
¿ÉÒÔÓÃSP_HELPTEXTÃüÁîÔÚ²éѯ·ÖÎöÆ÷Öв鿴´´½¨´æ´¢¹ý³ÌµÄÎı¾ÐÅÏ¢£¬¿ÉÒÔʹÓÃSP_HELP²é¿´´æ´¢¹ý³ÌµÄÒ»°ãÐÔÏ¢£¬¿ÉÒÔÓÃSP_RENAMEÀ´Ð޸Ĵ洢¹ý³ÌÃû¡£
ÀýÈ磺
USE ÏúÊÛ¹ÜÀí
GO
SP_HELPTEXT
GO
·µ»ØÐÅϢΪ´´½¨´æ´¢¹ý³ÌµÄÏà¹ØÓï¾ä¡£
3.Ö´Ðд洢¹ý³Ì
×¢Ò⣬Åú´¦ÀíÖ´ÐС£
¸ñʽ£º
EXCUTE(or EXEC) <¹ý³ÌÃû> ²ÎÊý
4.ɾ³ý´æ´¢¹ý³Ì
¸ñʽ£º
DROP PROCEDURE ¹ý³ÌÃû
5.Ð޸Ĵ洢¹ý³Ì
¸ñʽ£º
ALTER PROCEDURE ¹ý³ÌÃû
AS
SQL Óï¾äÐòÁÐ
Èý£®´æ´¢¹ý³ÌµÄÓŵã
1.Ö´ÐÐËٶȿ졣´æ´¢¹ý³ÌÊÇÒ»×éÔ¤±àÒëºÃµÄSQL´úÂ룬ÔÚ´´½¨Ê±ÒѾ¾¹ýÁËÓï·¨¼ì²éºÍÐÔÄÜÓÅ»¯£¬Òò´ËÔÚÖ´ÐÐʱ²»±ØÖظ´ÕâЩ²½Öè¡£
2.Ä£¿é»¯µÄ³ÌÐòÉè¼Æ¡£Óû§¿ÉÒÔ°´ÕÕÌض¨µÄ¹¦ÄÜÉè¼Æ²»Í¬µÄ´æ´¢¹ý³Ì¹©¹²ÏíʹÓá£
3.¼õÉÙÍøÂçͨÐÅÁ¿¡£Æä°üÀ¨ÁË´óÁ¿µÄT--SQL´úÂ룬ʹÓÃʱֻÐèÒªÓÃÒ»ÌõÓï¾äÀ´µ÷Óü´¿É£¬Õâ´ó´ó¼õÉÙÁËÍøÂçÉϵÄÊý¾Ý´«Êä¡£
4.±£Ö¤ÏµÍ³µÄ°²È«ÐÔ¡£Óû§Í¨¹ý´æ´¢¹ý³ÌÀ´·ÃÎʲÙ×÷Êý¾Ý£¬µ«²»ÄܶÔÊý¾Ý¿â½øÐвÙ×÷£¬±£»¤ÁËÊý¾ÝµÄ°²È«ÐÔ¡£
Ïà¹ØÎĵµ£º
ÎÊÌâ±³¾°£º
¡¡¡¡ÈÕ³£¶ÔSql Server 2005¹ØϵÊý¾Ý¿â½øÐвÙ×÷ʱ£¬ÓÐʱ¶ÔÊý¾Ý¿â£¨È磺SharepointÍøÕ¾ÅäÖÃÊý¾Ý¿âÃû
Sharepoint_Config£©½øÐÐЩ²»Õý³£²Ù×÷ÈçÊý¾Ý¿âÔÚ¶Áдʱ¶øÎÞ¹ÊÍ£Ö¹Êý¾Ý¿â£¬´Ó¶øµ¼ÖÂSql Server 2005Êý¾Ý¿â²»Õý³£
Öжϣ¬µ±Ôٴδò¿ªÊý¾Ý¿âʱ»á·¢ÏÖijЩÊý¾Ý¿â»á±»±ê¼ÇΪ“¿ÉÒÉ”£¨suspect)£¬¼´ÔÚÊý¾ ......
-- ˵Ã÷:
-- 1. Ҫɾ³ý±í table_name, ÐëÏÈÅжϸñíÊÇ·ñÕý±»Êý¾Ý¿âÖÐÆäËü±íËùÒýÓÃ.
-- 2. Èç¹ûδ±»ÒýÓÃ, ¿ÉÖ±½Ó DROP TABLE table_name; ·ñÔò±ØÐëÏÈɾ³ýÒýÓñíµÄÔ¼Êø, ÔÙ DROP TABLE table_name.
-- 3. ÁíÍâ, table_name ÊÇ·ñÕýÒýÓÃÆäËü±íµÄÇé¿öÎÞÐ뿼ÂÇ.
-- ´´½¨Ö÷±í
CREATE TABLE tParent
......
Ö´ÐÐ Êý¾Ý¿â²éѯʱ£¬ÓÐÍêÕû²éѯºÍÄ£ºý²éѯ֮·Ö¡£
Ò»°ãÄ£ºýÓï¾äÈçÏ£º
SELECT ×ֶΠfrom ±í WHERE ij×ֶΠLike Ìõ¼þ
ÆäÖйØÓÚÌõ¼þ£¬SQLÌṩÁËËÄÖÖÆ¥Åäģʽ£º
1£¬%£º±íʾÈÎÒâ0¸ö»ò¶à¸ö×Ö·û¡£¿ÉÆ¥ÅäÈÎÒâÀàÐͺͳ¤¶ÈµÄ×Ö·û£¬ÓÐЩÇé¿öÏÂÈôÊÇÖÐÎÄ£¬ÇëÔËÓÃÁ½¸ö°Ù·ÖºÅ£¨%%£©±íʾ¡£
±ÈÈç SELECT * from [user] WHERE u_na ......
SQL Server 2008ÖеıíÖµÐͲÎÊý
×÷ÕߣºAl Tenhundfeld ÒëÕß Õź£Áú¡¡
±íÖµÐͲÎÊý£¨Table-valued parameters£©ÊÇSQL Server 2008ÖÐÒýÈëµÄÒ»ÖÖÐÂÌØÐÔ£¬ËüÌṩÁËÒ»ÖÖÄÚÖõķ½Ê½£¬Èÿͻ§¶ËÓ¦ÓÿÉÒÔֻͨ¹ýµ¥¶ÀµÄÒ»Ìõ²Î»¯ÊýSQLÓï¾ä£¬¾Í¿ÉÒÔÏòSQL Server·¢ËͶàÐÐÊý¾Ý¡£
±íÖ ......
¸ÅÊö
Microsoft SQL Server 2008 ÈÃÄúÄܹ»Í¨¹ýÖ±¹ÛµÄÊý¾ÝÍÚ¾òµÄÔ¤²âÐÔ·ÖÎöÀ´×ö³öÃ÷ÖǺÏÀíµÄ¾ö²ß£¬ÎÞ·ìµØÕûºÏ Microsoft ÉÌÒµÖÇÄÜƽ̨²¢¿ÉÀ©Õ¹ÖÁÉÌÒµÓ¦ÓóÌÐò¡£
ÖØ´óµÄй¦ÄÜ
ͬʱÀûÓôíÎóºÍ¾«È·¶ÈµÄͳ¼Æ·ÖÊýÀ´²âÊÔ¶à¸öÊý¾ÝÍÚ¾òÄ£ÐÍ£¬²¢ÀûÓý»²æÑéÖ¤À´È·ÈÏÆäÎȶ¨ÐÔ
ÔÚµ¥Ò»½á¹¹Öн¨Á¢¶à¸ö²»¼æÈݵÄÍÚ¾òÄ£ÐÍ¡¢ÔÚɸѡ¹ýµÄÊ ......