sql server是sybase的兒子,所以 和sybase一樣兩者中都有BCP工具,使用這個工具可以大容量導入或者導出數據..以下就這兩類數據庫中的倒出所通用的一個BCP批處理..
@echo off
set server=testdb
set user=sa
set password=
echo use testdb > tabinfo.txt
echo go >>tabinfo.txt
echo select name from sysobjects where type =''U'' order by name >>tabinfo.txt
echo go >>tabinfo.txt
isql -S%server% -U%user% -P%password% -i tabinfo.txt -o out.txt
echo begin bcp out > bcpout.log
echo begin bcp out
for /F "eol=( skip=2 delims= " %%i in (out.txt) do echo %%i & bcp testdb.dbo.%%i out %%i -k -n -S%server% -U%user% -P%password% >>bcpout.log
echo " " >>bcpout.log
echo finish bcp out >> bcpout.log
echo bcp out finish, for result to see bcpout.log
del tabinfo.txt
del out.txt
pause