SSDT generate and publish database changes - sql-server

I am currently using the following command to generate a database script using SSDT:
"C:\Program Files\Microsoft SQL Server\150\DAC\bin\SqlPackage.exe" /Action:Script /sf:DB.dacpac /Profile:publish.xml /op:Script.sql
and the following command to publish:
"C:\Program Files\Microsoft SQL Server\150\DAC\bin\SqlPackage.exe" /Action:Publish /sf:DB.dacpac /Profile:publish.xml
Is there anyway we can merge them so it can generate a script (for audit purpose) as well as publish on the database?

Yes, it is quite recent but when you publish you can also use "/DeployScriptPath:" and give it a path and it will save the script.
Older versions of SSDT you had to do exactly what you are doing but we can now use this to do it in one step.
This will have the latest sqlpackage.exe in case you need it:
https://www.nuget.org/packages/Microsoft.Data.Tools.Msbuild/
ed

Related

Balanced Data Distributor Installation Error

I am working with SQL Server 2014 SP3 x64 and i have installed the cumulative update 1.
I have installed Visual Studio 2013 Professional and SQL Server Data Tools - Business Intelligence for Visual Studio and it works perfectly (I can design an run SSIS packages without any issue).
I downloaded SSIS Balanced Data Distributor for the following Microsoft download Links:
Microsoft® SQL Server® 2014 SP2 Feature Pack
Microsoft® SQL Server® 2014 Feature Pack
When I run the installation packages (both x64 and x86 - from both links), I get the following Error:
Problem with this windows installer package. A program run as part of the installation did not finish as expected. Contact your support personnel or package vendor
I tried to run the .msi as administrator from cmd with no luck. (I am a member of administrators)
I also checked the following link Problem in Installing the Balanced data Distributor for SSIS 2012 which is about the same error, but i think this is a different situtation.
Any Suggestion?
Step-by-Step solution
First I executed the .msi package with logging
msiexec /i BalancedDistributor-amd64.msi /l*v "install.log"
I checked the log file untill i found the following error:
MSI (s) (5C:EC) [12:32:01:306]: Product: Microsoft Balanced Data Distributor for SQL Server 2014 (x64) -- Error 1722. There is a problem with this Windows Installer package. A program run as part of the installation did not finish as expected. Contact your support personnel or package vendor. Action RegisterBDD32, location: C:\Program Files (x86)\Microsoft SQL Server\120\DTS\PipelineComponents\, command: regsvr32.exe /s "C:\Program Files (x86)\Microsoft SQL Server\120\DTS\PipelineComponents\TxBDD.dll"
Which means that the package encountered an error during the Dll registration.
I extracted the .msi package using 7zip , and it contains two files BDDDll32 and BDDDll64
I renamed these files to TxBDD.dll (from the installation log this is the original name of the DLL)
I copy the files to the following directories:
32-bit >> C:\Program Files (x86)\Microsoft SQL Server\120\DTS\PipelineComponents
64-bit >> C:\Program Files\Microsoft SQL Server\120\DTS\PipelineComponents
After that i started cmd as Administrator and i executed the following commands:
regsvr32.exe /s "C:\Program Files (x86)\Microsoft SQL Server\120\DTS\PipelineComponents\TxBDD.dll
regsvr32.exe /s "C:\Program Files\Microsoft SQL Server\120\DTS\PipelineComponents\TxBDD.dll
After that i started Visual Studio and on SSIS toolbox i click Refresh Items, and the Balanced Data Distributor is shown.
Side Note: After checking the Event Viewer >> Windows Log >> Application, i also found the Error message listed above
References
How to extract msi files to your computer
How to see the log files of msi package installation?
Adding Custom Components to SSIS

'sqlpackage.exe' is not recognized as an internal or external command Error

I used maven,Microsoft SQL server management studio 17.SQL server verion is 14.0.1000.169.
When i build my project it gives following error and build failed
'sqlpackage.exe' is not recognized as an internal or external command,
operable program or batch file.
[ERROR] The following errors occured during execution:
[ERROR] 'sqlpackage.exe' is not recognized as an internal or external command,
[ERROR] operable program or batch file.
This is my system environment path variables.
I can't find what's the wrong
I didn't have the location of sqlpackage.exe in the PATH variable. After adding it to PATH variable, had resolved the issue for me. (Something like below)
C:\Program Files\Microsoft SQL Server\140\DAC\bin
It's fixed using following steps.
You need to Install Sql server data tools
For that follow this steps.
For windows,
Install chocolatey
Install SSDT components
Add sqlpackage.exe to classpath
For Install chocolatey
https://chocolatey.org/install
For Install SSDT components
choco install sqlserver-cmdlineutils
choco install sql2014.clrtypes
choco install sql2014-sqldom
choco install sql2014-dacframework
For Add sqlpackage.exe to classpath
RUN setx PATH "%PATH%;C:\Program Files\Microsoft SQL Server\120\DAC\bin\;"
Looks like you havn't installed Data-tier Application Framework. You can download and install DacFx (17.4.1) from https://www.microsoft.com/en-us/download/details.aspx?id=56508
Adding these locations into path variable will fix both maven and gradle error if you already installed mssql server 2019.
C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn
Download Microsoft SQL Server Data-Tier Application Framework from https://www.microsoft.com/en-us/download/details.aspx?id=56508 and open Environment settings and set the PATH variable to C:\Program Files\Microsoft SQL Server\140\DAC\bin
try following:
install https://dotnet.microsoft.com/download/dotnet/3.1
install https://learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage-download?view=sql-server-ver15
run this command in terminal in projects directory(without braces) "dotnet add package Microsoft.SqlServer.DACFx"

SQL Server Config manager error: Cannot connect to WMI provider

I cant open my SQL server configuration manager getting this error message:
Cannot connect to WMI provider. You do not have permission or the server is unreachable. Note that you can only manage SQL Server 2005 and later servers with SQL Server Configuration Manager.
Invalid
I have searched online material and ran the mofcomp command as recommended: mofcomp “C:\Program Files (x86)\Microsoft SQL Server\120\Shared\sqlmgmproviderxpsp2up.mof”
I am now getting this error message:
MOF file has been successfully parsed
Storing data in the repository…
An error occurred while processing item 10 defined on lines 73 – 79 in file C:\Program Files (x86)\Microsoft SQL Server\120\Shared\sqlmgmproviderxpsp2up.mof:
Compiler returned error 0x80070005Error Number: 0x80070005, Facility: Win32
Description: Access is denied.
Can you please help me out, been 2 weeks sited with this problem
Run Cmd as Administrator and execute these commands:
First go to SQL Shared folder according to your sql version:
SQL 2008: C:\Program Files (x86)\Microsoft SQL Server\100\Shared\
SQL 2012: C:\Program Files (x86)\Microsoft SQL Server\110\Shared\
SQL 2014: C:\Program Files (x86)\Microsoft SQL Server\120\Shared\
SQL 2017: C:\Program Files (x86)\Microsoft SQL Server\140\Shared\ -------> My version is 2017
SQL 2019: C:\Program Files (x86)\Microsoft SQL Server\150\Shared\
Find more versions here
cd "C:\Program Files (x86)\Microsoft SQL Server\140\Shared"
Then:
mofcomp sqlmgmproviderxpsp2up.mof
Update:
The problem occurs because the Windows Management Instrumentation (WMI) provider configuration file for manage SQL Server services is missing. So the mofcomp command repairs or recreates it.
Here is more explanation:
https://learn.microsoft.com/en-us/windows/desktop/wmisdk/mofcomp
Run the #Fereydoon Barkzehy codes with Administrative Access
Sample -
cd C:\Program Files (x86)\Microsoft SQL Server\110\Shared
cd C:\Program Files (x86)\Microsoft SQL Server\140\Shared
mofcomp sqlmgmproviderxpsp2up.mof
depends on where the file "sqlmgmproviderxpsp2up.mof" is present
Youtube video
The best solution for me was to uninstall the instance and reinstall a fresh instance. This worked 100%.
What worked for me was to download the SQLEXPR_x64_Enu, run the Setup.exe and use the Repair option.
I have the same issue but it is not working at first. Second I already restarted my PC but it is not working either. What I found out is that you will run this on the folder where your SQL Server Management Studio is installed and not on the MS SQL Instance folder.
My SQL Server Management Studio which is 2016 is installed in
C:\Program Files (x86)\Microsoft SQL Server\130
But I keep on running changing folder on which I installed on my SQL Server 2012 instance:
C:\Program Files (x86)\Microsoft SQL Server\110\Shared\
After that, just run the command: mofcomp sqlmgmproviderxpsp2up.mof as everyone suggest in here.
So keep it mind the folder since that may affect your troubleshooting.
By trial and error I finally found this working solution:
I searched all sqlmgmproviderxpsp2up.mof files under C:\Program Files (x86)\Microsoft SQL Server
Running CMD as administrator I did for each result found above:
i) Change directory to go to the directory
ii) Run mofcomp sqlmgmproviderxpsp2up.mof
Reboot
Then, it works.
doing a fresh OS installation also worked for me as well. but this is a pain. Sometimes you can run the:
“C:\Program Files (x86)\Microsoft SQL Server\120\Shared\sqlmgmproviderxpsp2up.mof”
Sometimes it helps and sometimes it doesn't, all you need to do is do a fresh OS installation and then SQL installation.

unable to run sharepoint powershell script from sql server agent job

I have a powershell script which is working fine from PowerShell ISE, the script will move the local files to SharePoint 365 documents. When I schedule a SQL server agent job using this script getting the error below.
Please advice me what I need to do to run this script.
abc\SQLServiceAcc. A job step received an error at line 10 in a
PowerShell script. The corresponding line is 'Add-Type -Path
"C:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"'. Correct the
script and reschedule the job. The error information returned by
PowerShell is: 'Could not load file or assembly 'file:///C:\Program
Files\Common Files\Microsoft Shared\Web Server
Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll' or one of its
dependencies. This assembly is built by a runtime newer than the
currently loaded runtime and cannot be loaded. '. Process Exit Code
-1. The step failed.
It depends how you are running the script and which version of SQL Server you are using.
Look at http://www.travisgan.com/2013/05/sql-server-agent-job-and-powershell.html

How can I remote run an SSIS package using DTEXEC?

I'm very new to using dtexec and to deploying SSIS packages (mostly just run them in VS). I would like to remote run a package that I have deployed to a server using DTEXEC...
The package name is SQL2012 Update Run. When I open up SSMS, the package is found under
Integration Services Catalogs -> SSISDB -> ServerUpdate -> Projects -> UpdateRun -> Packages -> SQL2012 Update Run
The server name is 1555\C1592.
I have tried all sorts of variations on using the /sql command, the /ser command, /dts, /file, I just can't seem to get it to run.
How would I use the dtexec utility to run the package at the specified location using integrated security?
Edit: Oh and there are 4 parameters, 3 are strings and one is an int16, how would I pass these in?
Thank you
Below is an example of how write dtexec with the dtsx file location and variable input.
example:
dtexec /F "C:\Temp\Test.dtsx" /SET \Package.Variables[User::Guess_A_Number].Properties[Value];3
Shell (Edit):
dtexec /F "<your_directory/<your_file>.dtsx" /SET \Package.Variables[<Your Variable>].Properties[Your Value];<Your Value>
Explanation:
/F is the location of your dtsx (SSIS) package
/SET to set your variables.
More info on dtexec:
TechNet Link
Hope this helps!

Resources