【问题标题】:how to make an installer with SQL Server database如何使用 SQL Server 数据库制作安装程序
【发布时间】:2013-09-19 06:06:00
【问题描述】:

我有一个库存系统和一个 SQL Server 数据库的导出,我想制作它的安装程序。但问题是如何安装 SQL Server 数据库?我可以在visual studio的安装程序制造商中加入它还是有其他方式?

【问题讨论】:

    标签: sql-server sql-server-2008 c#-4.0


    【解决方案1】:

    不确定 Visual Studio 安装程序,但you can in WiX

    【讨论】:

      【解决方案2】:

      我们使用的解决方案是将 SQL 数据库导入 Sql Server Data Tools (SSDT): http://msdn.microsoft.com/en-us/data/tools.aspx

      然后我们使用 SSDT 的 DACPAC 功能来构建可以使用 SQL UI 或 powershell 脚本部署的数据库包,这是我们使用的基本脚本:

      cls
      
      #get current folder
      $invocation = (Get-Variable MyInvocation).Value
      $directorypath = Split-Path $invocation.MyCommand.Path
      
      #path to dac processing executables
      $sqlPackagePath = “C:\Program Files\Microsoft SQL Server\110\DAC\bin\sqlpackage.exe”
      
      ## detect the publish file and detect the dacpac
      $DacpacPath = $directorypath
      $PublishProfile = $directorypath
      
      foreach ($file in Get-ChildItem $directorypath)
      {
          if ($file.Name.Contains("ssdt.dacpac"))
          {
              $DacpacPath = $file.Name
      
          } elseif ($file.Name.Contains(".publish.xml"))
          {
              $PublishProfile = $file.Name
          }
      }
      
      # execute the command to deploy the database
      & $sqlPackagePath -Action:Publish -Profile:$PublishProfile -SourceFile:$DacpacPath | Out-File dacpac.log
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多