[英]Migrating from SQL DMO to SQL SMO (SQL Server 2012)
I am migrating the SQL DMO logic to a SQL SMO logic and I am not sure how to achieve the same functionality for a few of the attributes. 我正在将SQL DMO逻辑迁移到SQL SMO逻辑,但不确定如何为某些属性实现相同的功能。 This is the DMO:
这是DMO:
oBCP = New SQLDMO.BulkCopy2
With oBCP
.ImportRowsPerBatch = ImportRowsPerBatch
.DataFilePath = Path.Combine(gtSysTempDir, "file.dat")
.LogFilePath = Path.Combine(gtSysTempDir, "file.log")
.ErrorFilePath = Path.Combine(gtSysTempDir, "file.err")
.MaximumErrorsBeforeAbort = 1
.DataFileType = SQLDMO.SQLDMO_DATAFILE_TYPE.SQLDMODataFile_TabDelimitedChar
End With
This is the SMO so far: 到目前为止,这是SMO:
trans = New Transfer
With trans
.ImportRowsPerBatch = ImportRowsPerBatch
.TargetDatabaseFilePath = Path.Combine(gtSysTempDir, "file.dat")
.TargetLogFilePath = Path.Combine(gtSysTempDir, "file.log")
'.ErrorFilePath = Path.Combine(gtSysTempDir, "file.err")
.MaximumErrorsBeforeAbort = 1
.DataFileType = SQLDMO.SQLDMO_DATAFILE_TYPE.SQLDMODataFile_TabDelimitedChar
End With
What are the equivalents, if they exist, of ImportRowsPerBatch (BatchSize?), ErrorFilePath, MaxErrorsBeforeAbort, and DataFileType? ImportRowsPerBatch(BatchSize?),ErrorFilePath,MaxErrorsBeforeAbort和DataFileType的等效项(如果存在)是什么? Thanks.
谢谢。
Despite what the MSDN says , Transfer
is not actually the equivalent of BulkCopy2
; 尽管MSDN说了什么 ,但是
Transfer
实际上并不等同于BulkCopy2
; it's intended for scripting/copying entire databases whereas BulkCopy2
is only for bulk copying data. 它用于脚本化/复制整个数据库,而
BulkCopy2
仅用于批量复制数据。 The settings don't correspond at all -- in particular, Transfer.TargetDatabaseFilePath
is supposed to be the location of a database file, whereas BulkCopy2.DataFilePath
is the location of the file where imported/exported data goes. 这些设置根本不对应-特别是,
Transfer.TargetDatabaseFilePath
应该是数据库文件的位置,而BulkCopy2.DataFilePath
是导入/导出数据所在的文件的位置。 Some bulk copy scenarios are handled by Transfer
, but most aren't. 某些大容量复制方案由
Transfer
处理,但大多数情况并非如此。
If you're not actually copying an entire database, you have several alternatives, none of which use SMO (which has no class for bulk copying as such): 如果您实际上并没有复制整个数据库,则有几种选择,其中一种都不使用SMO(没有这样的类来进行批量复制):
BulkCopy2
does in the background (but I haven't verified this); BulkCopy2
在后台执行的操作(但我尚未对此进行验证); Of these, BULK INSERT
is the most straightforward. 其中,
BULK INSERT
是最简单的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.