sql server和sybase中通用的使用BCP倒出當前庫中所有表的數據批處理腳本

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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章