Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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¡£Æä´Î£¬ÔËÐÐÏÂÃæ´úÂëÖ´Ðиô洢¹ý³Ì¡£×îºó£¬»ùÓÚ´«»ØµÄÖµ¿ÉÒÔ²éѯÈËÔ±µÄÐÕÃûºÍµ


Ïà¹ØÎĵµ£º

SQL server 1068´íÎó

ÏÖÏó£º
   ÎҵĵçÄÔ--¹ÜÀí--·þÎñ--mssqlserver ·þÎñ --Æô¶¯
   ±¨´í£¬1068£¬
   »òÕߣ¬sqlserver ÅäÖùÜÀíÆ÷ÖÐSqlServer Ö÷·þÎñÆô¶¯ ±¨´í Ìáʾ˵ÒÀ´æµÄ·þÎñ»òÕß×é¼þûÓÐÆô¶¯£¬
Ô­Òò£ºÎÒÊDzËÄñ£¬²»Ì«Àí½âµ½µ×ʲôԭÒò£¬µ«ÊÇÕÒµ½Á˽â¾ö·½·¨
  
½â¾ö·½·¨£º
   SqlSe ......

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


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

SQL Server¹ÊÕÏÐÞ¸´¼¼ÇÉ

SQL Server 2005 ºÍ 2008 Óм¸¸ö¹ØÓڸ߿ÉÓÃÐÔµÄÑ¡ÏÈçÈÕÖ¾´«Êä¡¢¸±±¾ºÍÊý¾Ý¿â¾µÏñ¡£ËùÓÐÕâЩ¼¼Êõ¶¼Äܹ»×÷Ϊά»¤Ò»¸ö±¸Ó÷þÎñÆ÷µÄÊֶΣ¬Í¬Ê±Õâ¸öÊý¾Ý¿â¿ÉÒÔÔÚÄãÔ­ÏȵÄÖ÷Êý¾Ý¿â³öÎÊÌâʱÉÏÏß²¢×÷ΪеÄÖ÷·þÎñÆ÷¡£È»¶ø£¬Äã±ØÐë¼ÇסµÄÊǽ«±¸Ó÷þÎñÆ÷Ìæ»»ÉÏÏßÖ»ÊÇÍê³ÉÁËÒ»°ëµÄ¹ÊÕÏÐÞ¸´¹¤×÷¡£
Òª±£Ö¤ÄãµÄÓ¦ÓÃÕý³£¹¤×÷£¬ÔÚÊý¾Ý¿â ......

asp.net½áºÏaspnetpagerÓÃsqlÓï¾ä·ÖÒ³

Êý¾Ý¿â²Ù×÷Àࣺ
¸´ÖÆ´úÂë ´úÂëÈçÏÂ:
/// <summary>
/// È¡µÃ×ÜÊý
/// </summary>
/// <returns></returns>
public string getTotal()
{
StringBuilder sb = new StringBuilder();
sb.Append("select count(*) total from Test");
DataTable dt = DBHelper.ExecuteDt(sb.ToString ......

SQLÓï¾ä¹Ø¼ü×ÖUNIONС֪ʶ

   ½ñÌìÔÚÓÃUNION½øÐн«Á½¸ö²éѯ½áºÏʱ£¬·¢ÏÖ¼ÓÁËtextÀàÐ͵Ä×ֶνøÈ¥¾Í±¨´íÁË£¬´íÎóÐÅÏ¢ÈçÏ£º
²»ÄÜÒÔ DISTINCT ·½Ê½Ñ¡Ôñ text¡¢ntext »ò image Êý¾ÝÀàÐÍ¡£
     ¾­¹ý·­ÔÄ×ÊÁϺó²ÅÖªµÀ£¬Ô­ÒòÔÚÓÚÈç´Ë²Ù×÷ ÎÞ·¨¶ÔtextÀàÐÍÅжÏÊÇ·ñÖظ´£¬ËùÒÔÒªÔÚUNIONºó¼Ó¸öALL¹Ø¼ü×Ö£¬ÈçÏ£º
select top ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ