How make use of Bulk Insert API?

时间:2015-06-25 18:47:18

标签: sql ssis sql-server-2012 oledb linked-server

I have a pair of linked SQL servers: ServerA and ServerB. I have the following statement I wish to execute: INSERT INTO [ServerB].[data_collection].[dbo].[table1] SELECT * FROM [ServerA].[data_collection].[dbo].[table1] However, as I was informed in a previous question I asked here, it turns out that the implicitly called 'sp_cursor' procedure cannot handle the 766 columns I am trying to copy from ServerA to ServerB, despite there being only a single row in the table. In the aforementioned previous question, I was told that the workaround is to set the access mode to be "Table or view - fast load". Unfortunately, this is slightly beyond my limit of SQL knowledge. In the comments of the aforementioned question's answer, I was advised the following: To pull this off it looks like you're going to have to do your work in an SSIS package. The key is that under the hood an INSERT BULK is being executed, as opposed to SP_cursor (which was producing error). According to this MSDN question there is no way to access it directly - it is only accessible via the Bulk Insert API's. Again, this is beyond the limit of my SQL knowledge. So how does one get from where I am now — having only a pair of linked servers — to the point where I can make use of the INSERT BULK queries?

1 个答案:

答案 0 :(得分:0)

SSIS很复杂,因为它功能丰富,如果你对此感到不舒服,我不建议走那条路。然而,由于这是一个直接的抓取和抓取,我认为你可以通过使用导入导出向导(基本上是非常简单的SSIS包的向导)来实现。详细说明可以在here找到。

选择源数据库和表,然后选择目标数据库和表,根据需要映射列,然后执行它以传输数据。您甚至可以将该过程保存为SSIS作业。祝你好运,希望这会有所帮助。