2

我正在尝试创建一个脚本,以便可以批量加载(SQL Server)以前通过 BCP 导出的表的整个数据库。

目前我有:

SET QUOTED_IDENTIFIER OFF --original
select 'BULK INSERT "EP88XXX..' + name + '" FROM ' + name + '.txt ' 
from sysobjects where type = 'U' order by name

返回:

BULK INSERT "EP88XXX..DBA_INDEXS" FROM DBA_INDEXS.txt 
BULK INSERT "EP88XXX..PSACCESSLOG" FROM PSACCESSLOG.txt 
BULK INSERT "EP88XXX..PSACCESSPRFL" FROM PSACCESSPRFL.txt 
BULK INSERT "EP88XXX..PSACTARCHIVE" FROM PSACTARCHIVE.txt 
BULK INSERT "EP88XXX..PSACTIVEXLIC" FROM PSACTIVEXLIC.txt

我需要在顶部的脚本中再添加两个命令(Wide Native 和 BCP 文件的路径)。下面的这个命令将在一个表上构建批量插入:

BULK INSERT HRPXXXB.dbo.TABLE1 FROM 'K:\SQL_Backup\BCP\HRPXXX_TABLE1.txt'  WITH  ( DATAFILETYPE   = 'widenative')

感谢回复

4

1 回答 1

0

尝试这个

select 'BULK INSERT "EP88XXX..' + name + '" FROM ' + name + '.txt 
WITH  ( DATAFILETYPE   = ''widenative'')"'  from sysobjects where type = 'U' 
order by name
于 2013-10-12T17:06:54.777 回答