隨筆-4  評論-0  文章-0  trackbacks-0
          從數(shù)據(jù)庫中把所有表數(shù)據(jù)導(dǎo)出: 
          1.編輯一個(gè)文件selectout.sql: 
          set nocount on
          use databasename
          go
          select 'bcp databasename..' + name + ' out d:\temp\' + name + '.txt -Uusername -Ppassword -Sservername -c ' from sysobjects where type='U'
          go
          2.在cmd中執(zhí)行: 
          isql -Uusername -Ppassword -Sservername -i d:\selectout.sql -o d:\bcpout.bat
          3.執(zhí)行d:\bcpout.bat文件, 可以把數(shù)據(jù)導(dǎo)出到d:\temp\目錄。 
          把所有表數(shù)據(jù)導(dǎo)入到數(shù)據(jù)庫時(shí),將上面的out改為in 

          4.bcp導(dǎo)入導(dǎo)出: 
          導(dǎo)出數(shù)據(jù):
          bcp DatabaseName.dbo.tableName out D:\tableName.txt -SServerName -Usa -P -c -b 10000
          導(dǎo)入數(shù)據(jù):
          bcp DatabaseName.dbo.tableName in D:\tableName.txt -SServerName -Usa -P -c -b 10000
          在導(dǎo)入大量數(shù)據(jù)時(shí)加上-b參數(shù),分批提交不以致于數(shù)據(jù)庫日志被塞滿。 
          posted on 2012-04-24 14:16 cuilihui 閱讀(2537) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 眉山市| 新河县| 汪清县| 桂东县| 龙游县| 江源县| 贡嘎县| 虞城县| 通河县| 丹巴县| 特克斯县| 曲松县| 新闻| 随州市| 江油市| 四川省| 万宁市| 亚东县| 小金县| 宝兴县| 京山县| 靖安县| 鸡泽县| 道真| 德阳市| 浦县| 突泉县| 搜索| 利川市| 凤阳县| 金塔县| 隆安县| 津南区| 增城市| 新晃| 嘉荫县| 公安县| 通海县| 伊通| 富川| 二连浩特市|