BCP大資料匯入匯出

2021-10-19 09:37:43 字數 1162 閱讀 3014

bcp命令列匯出匯入大資料

首先看匯出:

要點:確保你安裝了microsoft command line utilities 15 for sql server (x64).msi這個包

進入command視窗,這個不用說了吧,都會的win+r,cmd

下面**為匯出資料,我的機器大概每秒10000多行,相信大家的都比我快

bcp lnbi.dbo.site_info out f:/aaa/aaa.txt -u"使用者名稱" -p"密碼" -s 你的伺服器ip位址 -t -k -c
生成資料表的格式檔案,命令如下:

bcp lnbi.dbo.site_info format nul -u"使用者名稱" -p"密碼" -s 你的伺服器ip -f f:/aaa/aaa.xml -t -c -x
匯入資料(是在伺服器上執行的):

--開啟xp_cmdshell儲存過程(開啟後有安全隱患)

-- 允許配置高階選項

exec master.sys.sp_configure 'show advanced options', 1

-- 重新配置

reconfigure

-- 啟用xp_cmdshell

exec master.sys.sp_configure 'xp_cmdshell', 1

--重新配置

reconfigure

insert into db_mgr.dbo.t_student(f_code, f_name) select f_code, f_name  

from openrowset(bulk n'c:/student_c.data', formatfile=n'c:/student_fmt_c.xml') as new_table_name -- t_student表必須已存在

select f_code, f_name into db_mgr.dbo.tt

from openrowset(bulk n'c:/student_c.data', formatfile=n'c:/student_fmt_c.xml') as new_table_name -- tt表可以不存在

bcp匯入匯出

匯出 set cmd n bcp select from 庫.dbo.test1 n queryout d voc txt c u liyuepeng p liyuepeng exec master.xp cmdshell cmd set cmd n bcp 庫.dbo.test2 n in d v...

使用BCP匯出匯入資料

bcp 實用工具可以在 microsoft sql server 例項和使用者指定格式的資料檔案間大容量複製資料。使用 bcp 實用工具可以將大量新行匯入 sql server 表,或將表資料匯出到資料檔案。除非與 queryout 選項一起使用,否則使用該實用工具不需要了解 transact sq...

使用BCP匯出匯入資料

bcp實用工具可以在 microsoft sql server 例項和使用者指定格式的資料檔案間大容量複製資料。使用bcp實用工具可以將大量新行匯入 sql server 表,或將表資料匯出到資料檔案。除非與queryout選項一起使用,否則使用該實用工具不需要了解 transact sql 知識。...