ͨ¹ýÅú´¦Àí£¬ÊµÏÖSQL ServerÊý¾Ý¿â¶¨ÆÚ±¸·Ýµ½ftp
@echo off
rem --------------------- ÅäÖÃ: ftpÉÏ´«²ÎÊý,¼°±¾µØÎļþĿ¼(Êý¾Ý¿â±¸·ÝµÄÁÙʱĿ¼)-----------------
set "PUT_FTP_SERVER=192.168.1.100"
set "PUT_FTP_PORT=21"
set "PUT_FTP_USERNAME=ftpuser"
set "PUT_FTP_PASSWORD=ftppasswd"
set "PUT_DIR=/"
set "LOCAL_DIR=D:\sql_dbbackup\"
rem ----------------------³ÌÐò¿ªÊ¼-----------------------------------------------------------------------
echo begin_backup_db
rem µ÷ÓÃÊý¾Ý¿â±¸·Ý´æ´¢¹ý³Ì,²ÎÊýΪ±¾µØĿ¼. Êý¾Ý¿â·µ»Ø"¹ýÆÚÐèҪɾ³ýµÄ±¸·ÝÎļþ"
sqlcmd -E -S 127.0.0.1,1333 -d master -v BAK_PATH="'%LOCAL_DIR%'" -Q "execute dbo.p_job_backup $(BAK_PATH);" -t 4800 -h -1 -W | findstr bak>>del_file.txt
rem ¿ªÊ¼×Ô¶¯ÉÏ´«(ÉÏ´«Íêɾ³ý¶ÔÓ¦µÄ±¾µØÎļþ)
echo begin_ftp_upload
call :uploaddir "%LOCAL_DIR%" "%PUT_DIR%"
rem ¼ì²éÊÇ·ñÉÏ´«Ê§°Ü,ʧ°ÜÔò¼Ç¼Êý¾Ý¿âÈÕÖ¾
echo begin_check
for /f "delims=" %%i in ('dir /b /a-d "%LOCAL_DIR%*.bak"') do echo %%~nxi>>local_file.txt
if not exist local_file.txt goto :delete_remote
for /f "delims=" %%i in (local_file.txt) do (
sqlcmd -E -S 127.0.0.1,1333 -d master -v FILE_NAME="'%%i'" -Q "insert into t_log_backup(loglevel, filename, remark) values(1,$(FILE_NAME),'ÑÏÖØ´íÎó:ÉÏ´«±¸·ÝÎļþʧ°Ü,Çë¼ì²éftpȨÏÞ.ͬʱËü»áµ¼Ö±¾µØ´ÅÅÌÂú.');" -t 3600
)
del /f/q local_file.txt
rem ¿ªÊ¼É¾³ýÔ¶³Ì¹ýÆÚÎļþ
echo begin_del_remote
:delete_remote
call :delremotefile "%LOCAL_DIR%" "%PUT_DIR%"
rem Æô¶¯Êý¾Ý¿â·¢ËÍÓʼþ(¼´·¢ËÍ´íÎóÈÕÖ¾)
sqlcmd -E -S 127.0.0.1,1333 -d master -Q "execute dbo.p_sendmail;" -t 120
echo end.
goto :eof
rem ---------------------³ÌÐò½áÊø-------------------------------------------------------------------------
rem ---------------------ÒÔϾùΪµ÷ÓõÄ×Óº¯Êý-------------------------------------------------------------
:uploaddir - upload directory tree
:: - %~1 local directory
:: - %~2 remote directory
setlocal
set "localdir=%~1"
set "remotedir=%~2"
call :put_autoftp cmdftp_uploaddir "
Ïà¹ØÎĵµ£º
1¡¢Á½±í£¬Ò»ÕÅÓÐÉÏ°ÙÍòµÄÊý¾Ý£¨±íA)£¬ÁíÒ»ÕÅÖ»ÓÐÒ»Íò¶àÌõÊý¾Ý£¨±íB£©£¬A±íµÄÍâ¼ü¹ØÁªµ½B±íµÄÖ÷¼üÉÏ¡£
ÎÊÏÂÃæÁ½ÌõSQLÓï¾ä£¬ÄÇÌõÐÔÄܸü¸ß£¿
(1)SELECT A.ID, B.ID from A, B WHERE A.FID = B.ID
(2)SELECT A.ID, B.ID from B, A WHERE A.FID = B.ID ......
´æ´¢¹ý³Ì
ÔÚ´óÐÍÊý¾Ý¿âϵͳÖУ¬Ëæ׏¦ÄܵIJ»¶ÏÍêÉÆ£¬ÏµÍ³Ò²±äµÃÔ½À´Ô½¸´ÔÓ£¬´óÁ¿µÄʱ¼ä½«»áºÄ·ÑÔÚSQL´úÂëºÍÓ¦ÓóÌÐò´úÂëÉÏ£¬¿öÇÒÔںܶàÇé¿öÏ£¬Ðí¶à´úÂë±»Öظ´Ê¹Óöà´Î£¬Ã¿´Î¶¼ÊäÈëÏàͬµÄ´úÂë¼È·±ËöÓֻήµÍϵͳÔËÐÐЧÂÊ¡£Òò´Ë£¬SQL ServerÌṩÁËÒ»ÖÖ·½·¨£¬Ëü¿ÉÒÔ½«Ò»Ð©¹Ì¶¨µÄ²Ù×÷¼¯ÖÐÆðÀ´ÓÉSQL ServerÊý¾Ý¿â·þÎñÆ÷À´Íê³É£ ......
´¥·¢Æ÷
´¥·¢Æ÷ÊÇÒ»ÖÖÌØÊâÀàÐ͵Ĵ洢¹ý³Ì£¬Ëü²»Í¬Ç°Ãæ½éÉܹýµÄ´æ´¢¹ý³Ì¡£´¥·¢Æ÷Ö÷ÒªÊÇͨ¹ýʼþ½øÐд¥·¢¶ø±»Ö´Ðеģ¬¶ø´æ´¢¹ý³Ì¿ÉÒÔͨ¹ý´æ´¢¹ý³ÌÃû³Æ¶ø±»Ö±½Óµ÷Óᣴ¥·¢Æ÷ÊÇÒ»¸ö¹¦ÄÜÇ¿´óµÄ¹¤¾ß£¬Ëüʹÿ¸öÕ¾µã¿ÉÒÔÔÚÓÐÊý¾ÝÐÞ¸Äʱ×Ô¶¯Ç¿ÖÆÖ´ÐÐÆäÒµÎñ¹æÔò¡£´¥·¢Æ÷¿ÉÒÔÓÃÓÚSQL ServerÔ¼Êø¡¢Ä¬ÈÏÖµºÍ¹æÔòµÄÍêÕûÐÔ¼ì²é¡£
µ±Íùijһ ......
Ë÷Òý²Ù×÷
Êý¾Ý¿âÖеÄË÷ÒýÓëÊé¼®ÖеÄË÷ÒýÀàËÆ£¬ÔÚÒ»±¾ÊéÖУ¬ÀûÓÃË÷Òý¿ÉÒÔ¿ìËÙ²éÕÒËùÐèÐÅÏ¢£¬ÎÞÐëÔĶÁÕû±¾Êé¡£ÔÚÊý¾Ý¿âÖУ¬Ë÷ÒýʹÊý¾Ý¿â³ÌÐòÎÞÐë¶ÔÕû¸ö±í½øÐÐɨÃ裬¾Í¿ÉÒÔÔÚÆäÖÐÕÒµ½ËùÐèÊý¾Ý¡£ÊéÖеÄË÷ÒýÊÇÒ»¸ö´ÊÓïÁÐ±í£¬ÆäÖÐ×¢Ã÷Á˸÷¸ö´ÊµÄÒ³Âë¡£¶øÊý¾Ý¿âÖеÄË÷ÒýÊÇij¸ö±íÖÐÒ»ÁлòÕßÈô¸ÉÁÐÖµµÄ¼¯ºÏ£¬ºÍÏàÓ¦µÄÖ¸Ïò±íÖÐÎïÀí±ê ......
sql CHARINDEXº¯Êý
SQL Server 2010-01-15 09:01:15 ÔĶÁ888 ÆÀÂÛ0 ×ֺţº´óÖÐС
CHARINDEXº¯Êý·µ»Ø×Ö·û»òÕß×Ö·û´®ÔÚÁíÒ»¸ö×Ö·û´®ÖеÄÆðʼλÖá£CHARINDEXº¯Êýµ÷Ó÷½·¨ÈçÏ£º
CHARINDEX ( expression1 , expression2 [ , start_location ] )
  ......