您的位置:首页 > 数据库

sql server和sybase中通用的使用BCP倒出当前库中所有表的数据批处理脚本

2011-11-08 15:35 465 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: