@echo off
rem -- =============================================
rem -- DESCRIPTION: <自動_導入バッチ>
rem -- AUTHOR: <>
rem -- CREATE DATE: <2010/12/27>
rem -- =============================================
rem --------------------------------------------------------------
rem コピー元タイプ_(default: txt)
rem --------------------------------------------------------------
@SET file_type1=.txt
rem -------------------------------------------------------------
rem from_データベース__name
rem -------------------------------------------------------------
@SET from_database_name=[project_guest126_back].[dbo]
rem -------------------------------------------------------------
rem to_データベース__name
rem -------------------------------------------------------------
@SET to_database_name=[project_guest126].[dbo]
rem -------------------------------------------------------------
rem テーブル__name
rem -------------------------------------------------------------
@SET table_name=.[Z_M_PART_STK_WK]
rem -------------------------------------------------------------
rem CONFIGファイル名
rem -------------------------------------------------------------
@SET config_file_name=CONFIG.TXT
rem -------------------------------------------
rem SQLサーバへデータが 導入成功
rem -------------------------------------------
@FOR /F "eol=# tokens=1,2,3* delims=, " %%i IN (%config_file_name%) DO (
BCP %to_database_name%%table_name% in %from_database_name%%table_name%%file_type1% -S%%i -U%%j -P%%k -c>>log.txt
IF errorlevel 1 GOTO error
)
@echo -- =============================================
@echo データが 導入成功しました。
@echo -- =============================================
@GOTO end
@:error
@echo -- =============================================
@echo データが 導入失敗しました。
@echo -- =============================================
@GOTO end
@:end
---------------------------------
----------------------------------
config.txt的内容
192.168.0.62,sa,password