首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SSIS包和SQL Server数据工具(这取代了BIDS)之间的区别是什么

SSIS包和SQL Server数据工具(这取代了BIDS)之间的区别是什么
EN

Stack Overflow用户
提问于 2016-12-08 04:36:07
回答 2查看 4.8K关注 0票数 2

我们有一些大的Excel文件(每个文件通常超过100MB )需要定期导入到SQL Server数据库中,我正在寻找自动执行此过程的选项。

听起来微软不再支持其业务智能开发工作室(BIDS),取而代之的是名为SQL Server Data Tools - Business Intelligence (SSDT-BI)的工具。

因此,我的选项似乎是SSDT-BI或SSIS包,但我不确定要使用哪一个。谁能提供一点关于这两个解决方案的信息?对于找到解决这个问题的任何建议,我们将不胜感激。

EN

回答 2

Stack Overflow用户

发布于 2019-08-29 07:58:39

我知道这是一个古老的帖子,它与SSIS或SSDT无关,但OP似乎在询问其他可能可用的选择。因此,我想为那些正在寻找一种简单的方法来导入提取文件而不需要使用这两个工具的人添加这篇文章。我已经创建了数以百计的进程,在那里我需要从提取文件(CSV,Access,Excel,FoxPro等)导入数据。下面是一个Powershell代码片段,它将加载Excel电子表格中的所有表格,然后简单地在数据网格中显示内容,但是您应该能够轻松地添加逻辑,例如将数据导入到表中。建设性的批评总是受欢迎的!

代码语言:javascript
复制
Clear-Host;
    ## You May Need to Download and Install the Microsoft Access Database Engine 2010 Redistributable: https://www.microsoft.com/en-us/download/details.aspx?id=13255

[String]$ExcelPath = "C:\Temp\TestSheet.xlsx";
[String]$TargetServer = "(local)";
[String]$TargetDatabase = "TestDB";

[String]$SourceConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 12.0 Xml;HDR=YES';" -f $ExcelPath;
[String]$TargetConnectionString = "Data Source={0};Initial Catalog={1};Trusted_Connection=True;" -f $TargetServer, $TargetDatabase;

$SourceFactory = [System.Data.Common.DbProviderFactories]::GetFactory("System.Data.OleDb");
$TargetFactory = [System.Data.Common.DbProviderFactories]::GetFactory("System.Data.SqlClient");

    $SourceConnection = $SourceFactory.CreateConnection();
        $SourceConnection.ConnectionString = $SourceConnectionString;
        $SourceConnection.Open();

    $SourceCommand = New-Object $SourceFactory.CreateCommand();
        $SourceCommand.Connection = $SourceConnection;
        $SourceCommand.CommandTimeout = [Int32]::MaxValue;

    $TargetConnection = $TargetFactory.CreateConnection();
        $TargetConnection.ConnectionString = $TargetConnectionString;
        $TargetConnection.Open();

    $TargetCommand = New-Object $TargetFactory.CreateCommand();
        $TargetCommand.Connection = $TargetConnection;
        $TargetCommand.CommandTimeout = [Int32]::MaxValue;

foreach($table in $SourceConnection.GetSchema("Tables").Rows){
    try{
            ## Source
                [String]$TabName = $table["TABLE_NAME"];
                [String]$sqlString = "SELECT * FROM [{0}];" -f $TabName;

                $SourceCommand.CommandText = $sqlString;

                [System.Data.Common.DbDataReader]$SourceDataReader = $SourceCommand.ExecuteReader();
                $dtData = New-Object System.Data.DataTable;
                    $dtData.Load($SourceDataReader);

            ## Target -- Bulk Insert data
                if($dtData.Rows.Count -gt 0){
                    $TabName = "[{0}]" -f $TabName;
                    $sqlBulkCopy = New-Object System.Data.SqlClient.SqlBulkCopy($TargetConnection);
                    $sqlBulkCopy.DestinationTableName = $TabName;

                    foreach ($Column in $dtData.Columns){
                        $sqlBulkCopy.ColumnMappings.Add($column, $column)
                    };

                    $sqlBulkCopy.WriteToServer($dtData);
                }
       }catch{
            $table["TABLE_NAME"];
            $_.Exception.Message;
            $_.Exception.ItemName;
        };
};

#Housekeeping
    $sqlBulkCopy.Close();
    $sqlBulkCopy.Dispose();

    $SourceCommand.Dispose();
    $SourceDataReader.Dispose();
    $SourceConnection.Close();
    $SourceConnection.Dispose();

    $TargetCommand.Dispose();
    $TargetDataReader.Dispose();
    $TargetConnection.Close();
    $TargetConnection.Dispose();

    $TargetConnection.Close();
    $TargetConnection.Dispose();
    [System.GC]::Collect();
票数 0
EN

Stack Overflow用户

发布于 2019-08-29 06:45:19

d/c b/n SSIS和SSDT不退出,但SSIS是SSDT的组成部分之一,即SSDT包含SSIS、SSRS和SSAS。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41026898

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档