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

SQL Server´æ´¢¹ý³ÌÈëÃÅ°¸ÀýÏê½â

ÎÊÌâÌá³ö
¡¡¡¡ÎÒʹÓùý¼¸´ÎSQL Server£¬µ«ËùÓÐÓëÊý¾Ý¿âµÄ½»»¥¶¼ÊÇͨ¹ýÓ¦ÓóÌÐòµÄ±àÂëÀ´ÊµÏֵġ£ÎÒ²»Öªµ½ÔÚÄÄÀïʹÓô洢¹ý³Ì£¬Ò²²»Á˽âʵÏÖ´æ´¢¹ý³ÌÐèÒª×öÄÄЩ¹¤×÷¡£Ï£ÍûÄÜÏêϸ˵Ã÷¡£
¡¡¡¡×¨¼Ò´ðÒÉ
¡¡¡¡´æ´¢¹ý³ÌÊÇ´æ´¢ÓÚÊý¾Ý¿âÖеÄÒ»×éT-SQLÓï¾ä¡£ÓÐÁË´æ´¢¹ý³ÌÖ®ºó£¬ÓëÊý¾Ý¿âµÄ½»»¥¾ÍûÓбØÒªÔÚ³ÌÐòÖÐдһ¶ÑµÄSQLÓï¾ä£¬¶øÖ»ÐèÓÃÒ»ÌõÓï¾äµ÷ ÓÃÊʵ±µÄ´æ´¢¹ý³ÌÀ´Íê³É¾Í¿ÉÒÔÁË¡£ÁíÍ⣬ÓÉÓÚ´úÂëÊÇ´æ´¢ÔÚÊý¾Ý¿âÖУ¬ÎÒÃÇÒ²¿ÉÒÔÔÚ²»Í¬µÄÓ¦ÓóÌÐò»ò²éѯ´°¿ÚÖв»¶ÏµÄÖظ´ÀûÓÃÄÇЩ´úÂë¡£ÏÂÃ潫½²ÊöһЩ¼òµ¥ µÄÀý×Ó£¬ËüÃǽ«ËµÃ÷ÈçºÎ¹¹ÔìºÍʹÓô洢¹ý³Ì¡£
¡¡¡¡ÏÂÃæµÄÀý×Ó½«¼òµ¥µÄ˵Ã÷ÈçºÎ´´½¨´æ´¢¹ý³Ì¡£ÒÔÏÂËùÓÐÀý×Ó¾ùʹÓÃAdventureWorksÊý¾Ý¿â¡£ÆäËüµÄÊý¾Ý¿âºÍÓ¦ÓóÌÐò¿ÉÒÔÒÀ´ËÀàÍÆ¡£
¡¡¡¡Àý 1 – ¼òµ¥µÄ´æ´¢¹ý³Ì
¡¡¡¡Õâ¸ö¼òµ¥µÄ´æ´¢¹ý³Ì½«ÊµÏÖÈçϹ¦ÄÜ£º´ÓPerson.Contact±íÖÐÈ¡³öµÚÒ»Ìõ¼Ç¼¡£
CREATE PROCEDURE uspGetContact
AS
SELECT TOP 1 ContactID, FirstName, LastName
from Person.Contact
¡¡¡¡´´½¨ÍêÉÏÃæµÄÓï¾äºó£¬Ê¹ÓÃÏÂÃæµÄÃüÁî¿ÉÒÔÖ´Ðиô洢¹ý³Ì¡£
EXEC uspGetContact
¡¡¡¡²éѯµÄ½á¹ûÈçÏ£º
¡¡¡¡Àý 2 – ´ø²ÎÊýµÄ´æ´¢¹ý³Ì
¡¡¡¡Õâ¸öÀý×ÓÔÚÉϸöÀý×ӵĻù´¡ÉÏ×öÁËÒ»µãÐ޸ģº´«ÈëÁËÒ»¸ö²ÎÊý£¬¸ù¾Ý´«ÈëµÄ²ÎÊýÀ´²éѯÏàÓ¦µÄ¼Ç¼¡£ÎªÁ˸üºÃµØÀûÓÃÉÏÃæµÄÀý×Ó£¬Õâ´ÎÎÒÃǾͲ»ÓÃÖØÐÂÔÙ ´´½¨Ò»¸ö´æ´¢¹ý³ÌÁË£¬¶øÊÇʹÓÃALTER PROCEDURE(×¢Ò⣺²»ÊÇCREATE PROCEDURE)À´ÐÞ¸ÄÀý1ÖÐÒѾ­´´½¨ºÃµÄ´æ´¢¹ý³Ì¡£´úÂëÈçÏ£º
ALTER PROCEDURE uspGetContact @LastName NVARCHAR(50)
AS
SELECT TOP 1 ContactID, FirstName, LastName
from Person.Contact
WHERE LastName = @LastName
¡¡ÏÂÃæÏÔʾÁËÔËÐд洢¹ý³ÌµÄ2ÖÖ²»Í¬·½·¨¡£µÚÒ»ÖÖ·½·¨½ö½ö´«ÈëÁËÎÒÃÇÏëÒªµÄ²ÎÊýÖµ¡£¶øµÚ¶þÖÖ·½·¨°üº¬Á˲ÎÊýÃûºÍ²ÎÊýÖµ¡£ÈÎÒâÒ»ÖÖ·½·¨¶¼¿ÉÒÔÔËÐиÃÀýÖеĴ洢¹ý³Ì¡£
EXEC uspGetContact 'Alberts'
EXEC uspGetContact @LastName='Alberts'
²éѯ½á¹ûÈçÏ£º
¡¡¡¡Àý 3 – ´øÊäÈëºÍÊä³ö²ÎÊýµÄ´æ´¢¹ý³Ì
¡¡¡¡Õâ¸öÀý×ÓÖмÈÓÐÊäÈë²ÎÊýÒ²ÓÐÊä³ö²ÎÊý¡£ÔÚ´æ´¢¹ý³ÌÖвéѯºóµÃµ½µÄContactID¿ÉÒÔÀûÓÃÊä³ö²ÎÊý½øÐлش«¡£»Ø´«²ÎÊýÓû§²éѯÈËÔ±±íÖеÄÆäËû×ֶΣ¬ÈçContactID¡¢FirstName¡¢LastNameÒÔ¼°Õâ¸öÈ˵ÄÈκεØÖ·¼Ç¼¡£
¡¡¡¡Ê×ÏÈ£¬ÎÒÃÇ°´ÈçÏ·½Ê½Ð޸Ĵ洢¹ý³ÌuspGetContact¡£Æä´Î£¬ÔËÐÐÏÂÃæ´úÂëÖ´Ðиô洢¹ý³Ì¡£×îºó£¬»ùÓÚ´«»ØµÄÖµ¿ÉÒÔ²éѯÈËÔ±µÄÐÕÃûºÍµ


Ïà¹ØÎĵµ£º

magento ÔÚMagentoÖлñÈ¡SQLÓï¾ä

       MagentoÊÇÔÚZend FrameworkµÄ»ù´¡Éϴ¶øÀ´£¬ÓÐÁ½ÖÖ·½Ê½¿ÉÒÔ´ÓMagentoµÄcollection»ñµÃÕæÕýµÄSQLÓï¾ä¡£
ÒÔ Mage::getResourceModel('reports/product_collection') ΪÀý£º
1
         $collection=Mage::getResourceModel('reports/product_collection'); ......

SQL 2005 ÖÐÊý¾Ýµ¼ÈëºÍµ¼³ö²Ù×÷²½Öè


ÒÔÇ°ÔÚ2000Àï¿ÉÒÔÊý¾Ýµ¼Èëµ¼³ö£¬µ±È»ÔÚ2005ÀïÒ²²»ÀýÍ⣬ͬÑùÓÐÕâÑùµÄ²Ù×÷£¬Ö»ÊÇÔÚ²Ù×÷ÉϺÍ2000ÓеãÇø±ð£¬ÏÂÃæͨ¹ýͼÎĵķ½·¨½ÌÄãÔõÑùµ¼Èëµ¼³öÊý¾Ý¡£
²Ù×÷²½Ö裺
1¡¢Èçͼ£¬ÔÚ“¶ÔÏó×ÊÁϹÜÀíÆ÷”ÀÓÒ»÷ÄãÒªµ¼Èëµ¼³öÊý¾ÝµÄÊý¾Ý¿â£¬Ñ¡Ôñ“ÈÎÎñ”ÀïµÄµ¼ÈëÊý¾Ý»òµ¼³öÊý¾Ý£¬ÎÒÕâÀïÒÔµ¼ÈëÊý¾ÝΪÀý£¬µ¼³öÊ ......

SQL ·ÖÒ³²éѯЧÂÊ

ÓÃT-SQL×öÊý¾Ý¿â·ÖÒ³²éѯҲÓкü¸ÄêÁË£¬µ«¶ÔÓÚ¸÷ÖÖ²éѯ·½·¨µÄд·¨Ò»ÖÁ¶¼Ã»ÔõôȥÀí»á£¬×î½ü²ÎÓëÁ˼¸¸öÏîÄ¿µÄ¿ª·¢£¬¼¸¸öÏîÄ¿ÖзÖÒ³²éѯµÄд·¨Ò²²»Ïàͬ£¬ÕâÒ²ÈÃÎÒ²úÉúÁËÈ·Èϼ¸ÖÖд·¨Ð§ÂÊÎÊÌâµÄÐËȤ¡££¨×¢£ºÎÒËù˵µÄ¼¸ÖÖд·¨¶¼ÊÇÐèÒª·µ»Ø×ܼǼÊýµÄ·ÖÒ³£©
1¡¢Éú³É²âÊÔÊý¾Ý
select a.* into test from sys.columns a,sys.colu ......

SQL Server 2008¶¨Ê±×÷ÒµµÄÖƶ¨£¨SQL2005²Î¿¼´Ë·½·¨£©

SQL Server 2008 ¶¨Ê±×÷ÒµµÄÖƶ¨
--1.´ò¿ª¡¾SQL Server Management Studio¡¿£¬ÔÚ¡¾¶ÔÏó×ÊÔ´¹ÜÀíÆ÷¡¿ÁбíÖÐÑ¡Ôñ¡¾SQL Server ´úÀí¡¿£»
--2.Êó±êÓÒ»÷¡¾SQL Server ´úÀí¡¿£¬Ñ¡Ôñ¡¾Æô¶¯(S)¡¿£¬ÈçÒÑÆô¶¯£¬¿ÉÒÔÊ¡ÂԴ˲½Ö裻
--3.Õ¹¿ª¡¾SQL Server ´úÀí¡¿ÁÐ±í£¬ÓÒ»÷¡¾×÷Òµ¡¿-->¡¾Ð½¨×÷Òµ¡¿£»
--3.1 ÔÚ¡¾³£¹æ¡¿Ñ¡ÏÖУº ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ