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

SQL ÁÙʱ±íÓëÁÙʱ±äÁ¿±í

 
         ÔÚSQLServerµÄÐÔÄܵ÷ÓÅÖУ¬ÓÐÒ»¸ö²»¿É±ÈÄâµÄÎÊÌ⣺ÄǾÍÊÇÈçºÎÔÚÒ»¶ÎÐèÒª³¤Ê±¼äµÄ´úÂë»ò±»Æµ·±µ÷ÓõĴúÂëÖд¦ÀíÁÙʱÊý¾Ý¼¯?±í±äÁ¿ºÍÁÙʱ±íÊÇÁ½ÖÖÑ¡Ôñ¡£ÈçºÎÈ·¶¨Ê²Ã´Ê±ºòÓÃÁÙʱ±í£¬Ê²Ã´Ê±ºòÓñí±äÁ¿ÄØ£¿ÁÙʱ±íºÍ±í±äÁ¿¶¼ÓÐÌض¨µÄÊÊÓû·¾³¡£
¡¡¡¡±í±äÁ¿
¡¡¡¡±äÁ¿¶¼ÒÔ@»ò@@Ϊǰ׺£¬±í±äÁ¿ÊDZäÁ¿µÄÒ»ÖÖ£¬ÁíÍâÒ»ÖÖ±äÁ¿±»³ÆΪ±êÁ¿(¿ÉÒÔÀí½âΪ±ê×¼±äÁ¿£¬¾ÍÊDZê×¼Êý¾ÝÀàÐ͵ıäÁ¿£¬ÀýÈçÕûÐÍint»òÕßÈÕÆÚÐÍDateTime)¡£ÒÔ@ǰ׺µÄ±í±äÁ¿ÊDZ¾µØµÄ£¬Òò´ËÖ»ÓÐÔÚµ±Ç°Óû§»á»°ÖвſÉÒÔ·ÃÎÊ£¬¶ø@@ǰ׺µÄ±í±äÁ¿ÊÇÈ«¾ÖµÄ£¬Í¨³£¶¼ÊÇϵͳ±äÁ¿£¬±ÈÈç˵@@error´ú±í×î½üµÄÒ»¸öT-SQLÓï¾äµÄ±¨´íºÅ¡£µ±È»ÒòΪ±í±äÁ¿Ê×ÏÈÊǸö±äÁ¿£¬Òò´ËËüÖ»ÄÜÔÚÒ»¸öBatchÖÐÉú´æ£¬Ò²¾ÍÊÇÎÒÃÇËù˵µÄ±ß½ç£¬³¬³öÁËÕâ¸ö±ß½ç£¬±í±äÁ¿Ò²¾ÍÏûÍöÁË¡£
¡¡¡¡´æ·ÅÔÚÄÚ´æÖУ¬ÕýÊÇÒòΪÕâÒ»µãËùÓÐÓû§·ÃÎʱí±äÁ¿µÄʱºòSQLServerÊDz»ÐèÒªÉú³ÉÖ¾¡£Í¬Ê±±äÁ¿ÊDz»ÐèÒª¿¼ÂÇÆäËû»á»°·ÃÎʵÄÎÊÌ⣬Òò´ËÒ²²»ÐèÒªËø»úÖÆ£¬¶ÔÓڷdz£·±Ã¦µÄϵͳÀ´Ëµ£¬±ÜÃâËøµÄʹÓÿÉÒÔ¼õÉÙÒ»²¿·Öϵͳ¸ºÔØ¡£
¡¡¡¡ÁíÍ⻹ÓÐÒ»¸öÏÞÖƾÍÊDz»ÄÜ´´½¨Ë÷Òý£¬µ±È»Ò²²»´æÔÚͳ¼ÆÊý¾ÝµÄÎÊÌ⣬Òò´ËÔÚÓû§·ÃÎʱí±äÁ¿µÄʱºòÒ²¾Í²»´æÔÚÖ´Ðмƻ®Ñ¡ÔñµÄÎÊÌâÁË(Ò²¾ÍÊÇÒÔΪ×űàÒë½×¶Îºó¾ÍûÓÐÓÅ»¯½×¶ÎÁË)£¬ÕâÒ»ÌØÐÔÓеÄʱºòÊǼþºÃÊ£¬¶øÓÐЩʱºòÈ´»áÔì³ÉһЩÂé·³¡£
¡¡¡¡ÁÙʱ±í
¡¡¡¡ÁÙʱ¶ÔÏó¶¼ÒÔ#»ò##Ϊǰ׺£¬ÁÙʱ±íÊÇÁÙʱ¶ÔÏóµÄÒ»ÖÖ£¬»¹ÓÐÀýÈçÁÙʱ´æ´¢¹ý³Ì¡¢ÁÙʱº¯ÊýÖ®ÀàµÄÁÙʱ¶ÔÏó£¬ÁÙʱ¶ÔÏ󶼴洢ÔÚtempdbÖС£ÒÔ#ǰ׺µÄÁÙʱ±íΪ±¾µØµÄ£¬Òò´ËÖ»ÓÐÔÚµ±Ç°Óû§»á»°ÖвſÉÒÔ·ÃÎÊ£¬¶ø##ǰ׺µÄÁÙʱ±íÊÇÈ«¾ÖµÄ£¬Òò´ËËùÓÐÓû§»á»°¶¼¿ÉÒÔ·ÃÎÊ¡£ÁÙʱ±íÒԻỰΪ±ß½ç£¬Ö»Òª´´½¨ÁÙʱ±íµÄ»á»°Ã»ÓнáÊø£¬ÁÙʱ±í¾Í»á³ÖÐø´æÔÚ£¬µ±È»Óû§ÔڻỰÖпÉÒÔͨ¹ýDROPTABLEÃüÁîÌáÇ°Ïú»ÙÁÙʱ±í¡£
¡¡¡¡ÎÒÃÇÇ°Ãæ˵¹ýÁÙʱ±í´æ´¢ÔÚtempdbÖУ¬Òò´ËÁÙʱ±íµÄ·ÃÎÊÊÇÓпÉÄÜÔì³ÉÎïÀíIOµÄ£¬µ±È»ÔÚÐÞ¸ÄʱҲÐèÒªÉú³ÉÈÕÖ¾À´È·±£Ò»ÖÂÐÔ£¬Í¬Ê±Ëø»úÖÆÒ²ÊDz»¿ÉȱÉٵġ£
¡¡¡¡¸ú±í±äÁ¿ÁíÍâÒ»¸öÏÔÖøÈ¥±ð¾ÍÊÇÁÙʱ±í¿ÉÒÔ´´½¨Ë÷Òý£¬Ò²¿ÉÒÔ¶¨Òåͳ¼ÆÊý¾Ý£¬Òò´ËSQLServerÔÚ´¦Àí·ÃÎÊÁÙʱ±íµÄÓï¾äʱÐèÒª¿¼ÂÇÖ´Ðмƻ®ÓÅ»¯µÄÎÊÌâ¡£
¡¡¡¡¼òµ¥µØ×ܽᣬÎÒÃǶÔÓÚ½ÏСµÄÁÙʱ¼ÆËãÓÃÊý¾Ý¼¯ÍƼöʹÓñí±äÁ¿¡£Èç¹ûÊý¾Ý¼¯±È½Ï´ó£¬Èç¹ûÔÚ´úÂëÖÐÓÃÓÚÁÙʱ¼ÆË㣬ͬʱÕâÖÖÁÙʱʹÓÃÓÀÔ¶¶¼ÊǼòµ¥µÄÈ«Êý¾Ý¼¯É¨Ãè¶ø²»ÐèÒª¿¼ÂÇʲôÓÅ»¯£¬±ÈÈç˵ûÓзÖ×é»ò·Ö×éºÜÉٵľۺÏ(±ÈÈç˵COUNT¡¢SU


Ïà¹ØÎĵµ£º

º½¿Õ¹«Ë¾¹ÜÀíϵͳ(VC++ ÓëSQL 2005)

ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
      ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......

ÔõÑù²ÅÄÜʵÏÖÅÅÐòÓÅ»¯µÄ²ã´Î¹Øϵ±íÉè¼Æ_SQL¼¼ÇÉ

 Êý¾Ý²ã´ÎµÄ¸ÅÄî:
Êý¾Ý²ã´ÎÊDZí´ïÊý¾ÝµÄÒ»ÖÖÖØÒª¹Øϵ£¬ÔÚÊý¾Ý¿âµÄÉè¼ÆÖУ¬È磺×éÖ¯½á¹¹·Ö½â¡¢¹¤×÷ÈÎÎñ·Ö½â¡¢ÐÐÕþÇø»®µÄ·Ö½âµÈ¶¼ÊDzã´Î¹ØϵÊý¾ÝµÄµäÐÍʵÀý¡£
±í´ï²ã´Î¹ØϵµÄÊý¾ÝÒ»°ãÐèҪʵÏÖÈçÏÂÊôÐÔ£º

 
1.²ã´ÎµÄ×î´ó¼¶Áª²ã´ÎÊý¡£È磺Öйú£­>ºþÄÏÊ¡->³¤É³ÊÐ->Ó껨Çø£¬¾ÍÊÇ4²ã¡£
2.ÄÜ·´Ó³Í¬Ò»² ......

´´½¨SQL ÓÐÎ󣿴íÔÚÄÄÄØ£¿

 
USE master
GO
CREATE DATABASE testbase2
ON
PRIMARY
(NAME = prim_sub_dat1,
FILENAME = 'G:\SQL SERVER2000\prim_sub_dat.mdf',
SIZE = 5MB,
MAXSIZE = 50MB,
FILEGROWTH = 20%),
(NAME = prim_sub_dat2,
FILENAME = 'G:\SQL SERVER2000\prim_sub_dat.ndf'
SIZE = 5MB,
MAXSIZE = 50MB,
......

¼òµ¥µÄsqlµÇ¼ºÍ×¢²á´æ´¢¹ý³Ì

 Ê×ÏÈÎÒ½¨ºÃÁËÒ»ÕÅÓû§±í±íÖÐÓÐÁ©¸ö×ֶΠһ¸öÊÇÕ˺ţ¬Ò»¸öÊÇÃÜÂ뵱ȻÕâÀïÎÒдµÄ֪ʶ¼òµ¥µÄµÇ¼ºÜ×¢²á£¬
±íÃ÷ users Óû§±í
×ֶΠaccountnum  varchar(50) --±íʾÕ˺Å
        password     varchar(50) --±íʾÃÜÂë
µÇ¼´æ´¢¹ý³Ì
create proc use_l ......

¶¯Ì¬SQL

Sample1:
/* Variable Declaration */
DECLARE @EmpID AS SMALLINT
DECLARE @SQLQuery AS NVARCHAR(500)
/* Build and Execute a Transact-SQL String with a single parameter value Using EXECUTE Command */
SET @EmpID = 1001
SET @SQLQuery = 'SELECT * from tblEmployees WHERE EmployeeID = ' + CAST(@EmpID A ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ