rem echo offrem Service Data Synchronization script rem variable settings rem sql command path set sql_bin= "c:\program files\ Microsoft sql server\100\tools\binn\sqlcmd. EXE "rem bcp command path set bcp_bin=" c:\program files\microsoft sql server\100\tools\binn\ Bcp.exe "rem Basic directory set base_dir=%~dp0rem setting source database information set so_user=" test "set so_pass=" test "set so_host= "192.168.1.22" set so_db=testset so_table=t1set so_table1=t2rem set target database information set des_user= "test" set des_pass= "test" set des_host= "127.0.0.1" Set des_db=testset des_ table=t1set des_table1=t2echo Exporting table Data %bcp_bin% %so_db%.dbo.%so_table% out %base _dir%%so_table%%date:~0,4%%date:~5,2%%date:~8,2%.csv -c -t "' | '" -r "| | |" -U %SO_USER% -P %SO_PASS% -S %SO_HOST%echo Importing table Data%bcp_bin% %d es_db%.dbo.%d Es_table% in %base_dir%%so_table%%date:~0,4%%date:~5,2%%date:~8,2%.csv -c&nBsp;-t "' | '" -r "| | |" -u %des_user% -p %des_pass% -s %des_host% del %base_dir%%so_table%% date:~0,4%%date:~5,2%%date:~8,2%.csv echo Exporting table Data %BCP_BIN% %SO_DB%.dbo.%SO_TABLE1% Out %base_dir%%so_table1%%date:~0,4%%date:~5,2%%date:~8,2%.csv -c -t "' | '" -r "| | |" -U %SO_USER% -P %SO_PASS% -S %SO_HOST%echo Importing table Data%bcp_bin% %d es_db%.dbo.%d Es_table1% in %base_dir%%so_table1%%date:~0,4%%date:~5,2%%date:~8,2%.csv -c -t "' | '" -r "| | |" -u %des_user% -p %des_pass% -s %des_host% del %base_dir%%so_table1%% Date:~0,4%%date:~5,2%%date:~8,2%.csv
This article is from the "Dead Leaf" blog, please make sure to keep this source http://mydbs.blog.51cto.com/513727/1745292
Batch processing of data through BCP guide table