How can I remote run an SSIS package using DTEXEC? - sql-server

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!

Related

Install SQL Server LocalDB on Server Core 2019 in Docker container

Within a Docker container (image = mcr.microsoft.com/windows/servercore:ltsc2019), I have downloaded the SQL Server Express 2019 installer.
I have successfully downloaded the LocalDB msi with:
SQL2019-SSEI-Expr.exe /Action=Download /MediaType=LocalDB /Quiet
The file is downloaded to:
C:\Users\ContainerAdministrator\Downloads\en-us\SqlLocalDB.msi
However... running msiexec fails without any error messages. After navigating to the path mentioned above, I execute:
msiexec.exe /qb /i .\SqlLocalDB.msi IAcceptSqlLocalDBLicenseTerms=YES
The command immediately drops back to the command line after zero delay. Nothing ever gets installed.
What am I missing?
Edit:
I'm trying to use LocalDB because this will eventually be an Azure Pipelines build agent. We use Redgate's "SqlChangeAutomation" powershell tools which uses LocalDB.
Edit 2:
Not sure if this is progress yet, however... I mucked around with msiexec logging for a bit and discovered I could run it with the /a flag instead of /i and get it to successfully install.
msiexec.exe /qn /a SqlLocalDB.msi IAcceptSqlServerLicenseTerms=YES /L*V "C:\installers\SQL\install.log"
Unfortunately, however, upon navigating to C:\Program Files\Microsoft SQL Server\150\tools\binn and running SqlLocalDB.exe info, I get this:
Call to LocalDBFormatMessage failed. Error code returned:
2311389462.
Error in LocalDBFormatMessage! Error code returned:
2311389462.
SQL LocalDB requires the Visual C++ redistributables, else many things won't go right (my problem was that SqlWriter service wouldn't create during install at all).
EDIT: it seems that I can use chocolatey to install the vc_redist and a older version of localdb. (Filing ticket to ask for the sqllocaldb package to be updated to 2019) so that would simplify things for most people. Keeping raw arguments/commands below just in case though.
My powershell steps for exact arguments (assuming you collect required files):
start-process .\VC_redist.x64.exe -Wait -ArgumentList #('/install','/norestart','/passive') Note I am using the redist from https://aka.ms/vs/16/release/vc_redist.x64.exe which should be the 2019, but spattering of comments say I should have used either the one in the SQL installer package, or some 2015 version. However neither of those "worked" for me in the containers, but that could have been me invoking them wrong. Besides which, further packages I need to install want 2019 anyways.
start-process msiexec -Wait -ArgumentList #('/i','SqlLocalDB.msi','/qn','/norestart','/L*V','install.log','IACCEPTSQLLOCALDBLICENSETE RMS=YES') Note that "/i" instead of "/a" worked correctly at this point, and the "/norestart" option. This was found from the choco localdb command source.
Useful powershell snippet to get some event logs (change "System" for "Application" for others) that helped me puzzle things out since no event-viewer in container: get-eventlog -LogName System -After (Get-Date).AddMinutes(-5) | ? {-not $_.Source.Contains("DCOM") } |?{-not $_.Message.Contains("depends on the Background Tasks Infrastructure Service")}| Format-List This and inspecting the "install.log" line-by-line from the SqlLocalDB.msi were what eventually led me on the right track.
I was trying to create images for pipelines too, installing via chocolatey, so I simply installed the chocolatey package for the redistributable too and that resolved the issue:
choco install vcredist-all -y
choco install sqllocaldb -y

SSDT generate and publish database changes

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

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

SSIS Parameters cannot be resolved by dtexec

I am trying to set a parameter while executing a package from command line
dtexec /f mypackage.dtsx /set \package.variables[$Project::MRNS_Database].Value;myvalue
I get the below error
The package path referenced an object that cannot be found:
"\Project.Variables[$Project::MRNS_Database]". This occurs when an
attempt is made to resolve a package path to an object that cannot be
found.
In fact the MRNS_Database is actually a parameter set at project level (I can see this under Parameters in Package Explorer). Also I am not able to use the /Par switch as i am using /File option.
How do i set the parameter in this case from command line dtsexec?
You have to specify ISPAC Project file as well, like this example
DTEXEC /Project "Path to proj\YourProj.ispac" /Package "yourpackage.dtsx"
/Set \Package.Variables[$Project::MRNS_Database];yourvalue
More details in Microsoft dtexec Reference.
As Ferdipux points out you need to reference your ispac file. Make sure you have builed your project otherwise it can cause errors.
Make sure everything is on ONE line if you use bat file.
I also included package parameters if you have those.
Bat file
#ECHO OFF
ECHO.
ECHO This is a batch file
ECHO.
DTEXEC.EXE /Project "C:\Users\thoje\Documents\Visual Studio 2015\Projects\Integration Services Project8\Integration Services Project8\bin\Development\Integration Services Project8.ispac" /Package Package24.dtsx /Set \Package.Variables[User::Test3].Value;1 /set \Package.Variables[$Package::Test2];1 /set \Package.Variables[$Project::Test4];1
PAUSE
CLS

SSIS Package and Bat file

How can I run a Stored Package with a .bat file? I am running it locally on a server.
To run a package from the command line, use the DTExec tool. The location of DTExec depends on the version of SQL you have installed. Assuming you have SQL Server 2008 R2, you could save the following text to a file with a .bat extension somewhere on your SQL server.
"C:\Program Files\Microsoft SQL Server\110\DTS\Binn\DTExec.exe" /f "D:\PathTo\MyPackage.dtsx"
Double click the the .bat file to execute the command above.
Here is more information on DTExec and BAT files.

Resources