我正在尝试创建一个脚本,以便我可以批量加载(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')
感谢回复
答案 0 :(得分:0)
试试这个
select 'BULK INSERT "EP88XXX..' + name + '" FROM ' + name + '.txt
WITH ( DATAFILETYPE = ''widenative'')"' from sysobjects where type = 'U'
order by name