SQL Server 2008 ¸´ÖÆ ·ÖÇøSWITCHÇåÀíÊý¾Ý
SQL Server 2008 ¸´ÖÆ ·ÖÇøSWITCHÇåÀíÊý¾Ý
³¡¾°£º
ijÖÖÌض¨ÒµÎñÏ£¬ÎÒÃǵIJ¿·ÖÒµÎñÊý¾Ý¿ÉÄÜÖ»»á±£Áô±È½Ï¶ÌµÄʱ¼ä£¬ÓÃÀ´×öÁÙʱ´¦Àí¡£ÒòΪ¿¼ÂǸ߿ÉÓõÄÌØÐÔ£¬¿ÉÄÜ»áÀûÓÃ
SQL ServerµÄ¸´ÖÆ×é¼þ¸´ÖÆÕâÖÖÊý¾Ýµ½ÁíÍâµÄ ÀàËÆÇ°¶Ë£¬²éѯÖÐÐĵÈÊý¾Ý¿â·þÎñÆ÷£¬´´½¨Ò»¸öÈßÓั±¾¡£¸´ÖÆ×é¼þ±ê¼ÇÊÂÎñÈÕÖ¾£¬×·×ÙËùÓеÄUpdate£¬Insert£¬Delete²Ù×÷¡£¿ÉÊÇÈç¹û²»¶¨ÆÚÇåÀíÕâÖÖ±í£¬ÄÇôÔÚÒ»¸ö¿ìËÙÔö³¤µÄ»·¾³Ï£¬±í±äµÄÓ·Öײ»¿°£¬²»½ö½öÀË·Ñ´ÅÅ̿ռ䣬¶øÇÒ¸øÐÔÄÜ´øÀ´Á˸ºÃæÓ°Ïì¡£
È磺
AÁÙʱÊý¾ÝÖÐÐÄ ---ͬ²½-->B ²éѯ/ÆäËûÒµÎñÖÐÐÄ£¬¸±±¾
±£Ö¤A²»¿ÉÓõÄʱºò£¬BµÄÒµÎñ²»ÒÀÀµÓÚA·þÎñÆ÷£¬ÀûÓÃAͬ²½¹ýÀ´µÄÊý¾ÝB×Ô¼ºÖ±½Ó´¦Àí¡£
³£¼ûµÄ½â¾ö·½°¸£º
Ò»¡¢ºÜ¼òµ¥µÄ£¬ÎÒÃÇ¿ÉÒÔÏëµ½£¬½¨Á¢Ò»¸öÇåÀíJob
£¬¸ù¾ÝÈÕÆÚ±êʶ£¬È·¶¨É¾³ýµÄ·¶Î§²»³öÒ»µã´íÎ󣬱ÈÈçÎÒÿÌìµÄÍíÉÏ12£º00ÒÔºóÇåÀí×òÌìµÄÊý¾Ý£¬ÄÇô¿ÉÄܻṹ½¨ÕâÑùµÄ²éѯ£¨ÅóÓÑÃÇ£¬Ò²Ðí»á˵ʹÓÃTRUNCATE
£¬×¼Ê±µÄ12£º00À´TRUNCATEµô£¬²»¹ýºÜ²»ÐÒµÄÊÇ£¬SQL
Server ¸´ÖÆÊÇÀûÓÃÈÕÖ¾±ê¼ÇµÄ·½Ê½À´Í¬²½Êý¾Ý£¬¶øTRUNCATEÓï¾ä²»»á±»ÈÕÖ¾±ê¼Ç£¬ËùÒÔTRUNCATEÓï¾äÔÚ¸´ÖƱíÖÐÊDZ»½ûÓõģ©
DELETE from dbo.t WHERE complete_time >=
'2010-05-04' AND
complete_time < '2010-05-05'
À´É¾³ý5ÔÂ4ºÅµÄËùÓÐÊý¾Ý£¬¿ÉÄÜÉÏÒÚÒ²¿ÉÄܸü¶à¡£
ÓÅ»¯·½°¸£ºÒòΪ¿¼Âǵ½´æÔÚ´øÁ¿µÄ¸üРɾ³ý ºÍ²åÈë²Ù×÷£¬ËùÒÔÊ×ÏȽ²Êý¾Ý¿âÉèÖóÉSIMPLE»Ö¸´Ä£Ê½£¬ÒÔ×îС»¯ÈÕÖ¾·½Ê½¡£
ÓÉÓÚDELETEµ¥¸öÓï¾äÊÇÒ»¸öÊÂÎñÐÔµÄÓï¾ä£¬ÒªÃ´È«²¿³É¹¦£¬ÒªÃ´È«²¿Ê§°Ü¡£ÄÇô¿ÉÏëÈç¹ûɾ³ýµÄÊÇÒÚ¼¶±ðµÄÊý¾Ý£¬ÄÇôÈÕÖ¾Ôö³¤,IO¸ººÉ·Ç³£µÄ´ó¡£
ËùÒÔ ¿ÉÄÜÓÅ»¯DELETE
²Ù×÷£º
WHILE 1=1
BEGIN
DELETE TOP(5000) from dbo.t
WHERE complete_time >= '2010-05-04' AND complete_time <
'2010-05-05'
IF @@ROWCOUNT<5000
BREAK;
END
½«É¾³ý²Ù×÷£¬Ëõ¶Ì³Éÿ5000ÐÐÒ»ÅúµÄÊý¾ÝÀ´´¦Àí¡£
ȱµã£ºÒòΪ´æÔÚ¸´ÖÆ£¬ÄÇôºÜÏÔÈ»£¬ÀË·ÑÁ˼«¶àµÄ´ø¿í£¬ÌرðÔÚInternetÕâÖÖ»·¾³Ï£¬ÀûÓÃVPNµÄÁ¬½Ó£¬ÓÈÆäÀË·Ñ¡£VPN´ø¿íÊ®·ÖµÄÃìС¡£ÔÙÕߣ¬ÔÚ½øÐÐÒÚ¼¶µÄDELETE£¬Ê±¼äºÄ·ÑÒ²ÊǷdz£¿Ö²ÀµÄ£¬¶øÇÒDELETE¹ý³ÌÖУ¬ÓÉÓÚ´æÔÚRange-X
·¶Î§ÅÅËûËø£¬Ðí¶à¿ª·¢ÈËÔ±
Ïà¹ØÎĵµ£º
½ñÌì´ÓÊý¾Ý¿âÖвéѯ³öxml£¬Í¬Ê±Ìí¼ÓÒ»¸ö¸ù½Úµã
×öÁËÈçϲâÊÔ£º
create table TestXmlQuery(
ID int identity(1,1) not null,
Name varchar(10)
)
go
insert into [TestXmlQuery] (Name) values('²âÊÔ1')
insert into [TestXmlQuery] (Name) values('²âÊÔ2')
insert into [TestXmlQuery] (Name) values('²âÊÔ3')
......
º¯Êý¼ò½é:¡¡¡¡
·µ»Ø Variant (Long) µÄÖµ£¬±íʾÁ½¸öÖ¸¶¨ÈÕÆÚ¼äµÄʱ¼ä¼ä¸ôÊýÄ¿¡£
º¯ÊýÓï·¨:
¡¡¡¡DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])
DateDiff º¯ÊýÓï·¨ÖÐÓÐÏÂÁÐÃüÃû²ÎÊý£º
¡¡¡¡interval ±ØÒª¡£×Ö·û´®±í´ïʽ£¬±íʾÓÃÀ´¼ÆËãdate1 ºÍ date2 µÄʱ¼ä²îµÄʱ¼ä¼ ......
ÓÉÓÚÍøÕ¾ÊDZðÈ˵Ä
sql server 2000 ²»Äܵ¼Èë2005 µÄÊý¾Ý¿âÎļþ ÎÒÖ»ºÃ°´ÕÕÊéÉÏÖØн¨Á¢µÄÊý¾Ý¿âÎļþ
È»ºóÔÚvisual studio 2005ÖÐÒ»¸öÒ»¸öµÄ¸´ÖÆ´æ´¢¹ý³Ìµ½sql server 2000
ÕâÑù¾Í²»ÓÃÏÂÔØ sql server 2005 ÁË
Èç¹ûÓÐsql server 2005 µÄ»°Ö®¼ÊÉú³É ½Å±¾¾ÍÒ»ÖÂÐÔµ¼Èë¾ÍokÁË ......
ÐèÇó£ºÓÐexcelÎļþ£¬º¬¶à¸ösheet£¬Ã¿¸ösheetµÄÄÚÈݶÔÓ¦²åÈëµ½Ò»ÕÅ±í£¬sheetµÄÃû³Æ¾ÍÊǶÔÓ¦µÄ±íÃû³Æ¡£
ÿһÐÐΪÁÐÃû£¬ÀýÈ磺
´ï³É£º½«Ã¿¸ösheetÊä³ö³ÉÒ»¸öÒÔsheetÃû³ÆÃüÃûµÄsqlÎļþ£¬ÄÚÈÝΪÿÐÐÄÚÈݵÄinsertÓï¾ä¡£
ÒÔÉÏͼΪÀý»áÉú³ÉÈý¸ösqlÎļþ£¬·Ö±ðÊÇTF_R_TERMINAL_ARCH.sql£¬ TF_R_STOCK_TRADE.sql ºÍ TF_R_STOC ......