Using SqlPackage.exe on a server without SSMS installed

家住魔仙堡 提交于 2020-08-05 09:27:44

问题


I have a windows 2012 server. The server can access my SQL database. I don't have access to the SQL database server, and I don't have access to install SSMS on the windows 2012 server running my website.

I want to use SqlPackage.exe to update my database scheme with a .dacpac file

I get the following error:

Unhandled Exception: System.TypeInitializationException: The type initializer for 'Microsoft.SqlServer.Dac.DacPackage' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Microsoft.SqlServer.Dac.DacServices' threw an exception. ---> System.TypeInitializationException: The type initializer for 'SqlSchemaModelStaticState' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.TransactSql.ScriptDom, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.

Is there some way that I can give SqlPackage.exe the needed Microsoft.SqlServer.TransactSql.ScriptDom without installing SSMS on the server?

If it is not possible, is there then an exsisting stand-alone exe out there that can do the job?


回答1:


SqlPackage come with SMSS or SQL Data Tools.

i see no other alternative than installing one of these two binaries to deploy dacpac, it is also possible from most computer running visual studio, because sql data tools is part of the defaults VS install.

https://msdn.microsoft.com/en-us/library/mt204009.aspx




回答2:


You can download any of these nuget packages (depending on desired version and platform). There you will find any missing DLLs.
https://www.nuget.org/packages?q=microsoft.sqlserver.dac+microsoft.sqlserver.dacfx

(Or you could write your own C#/Powershell application, using Microsoft.SqlServer.Dac.DacServices directly from the package.)




回答3:


Since Aug 2018 your best bet is to download the "Windows .NET Core .zip file" from https://docs.microsoft.com/en-us/sql/tools/sqlpackage-download?view=sql-server-2017#get-sqlpackage-net-core-for-windows




回答4:


This seemed to be the "smallest" package I could install and still get the tool (sqlpackage.exe) that works.

Microsoft® SQL Server® Data-Tier Application Framework (June 30 2016)

https://www.microsoft.com/en-us/download/confirmation.aspx?id=53013

the above installed it to the below directory when I install it (today)

C:\Program Files\Microsoft SQL Server\130\DAC\bin\SqlPackage.exe

APPEND:

Mid 2020 URL Update :

Microsoft® SQL Server® Data-Tier Application Framework (18.3.1)

https://www.microsoft.com/en-us/download/details.aspx?id=100297




回答5:


Usually you install SSDT to do this. I'm not sure if theres a portable version of SSDT somewhere that doesn't require an install if thats what you actually require.



来源:https://stackoverflow.com/questions/40913501/using-sqlpackage-exe-on-a-server-without-ssms-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!