1

I'm copying SSIS packages from one SQL server to another in a C# program via DTUTIL. The packages are in MSDB.

string dtutilCmd = "/c DTUTIL /SOURCESERVER " + sourceServer + " /SQL " + myPackage + " /DestServer " + destServer + " /COPY " + myPackage;

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = dtutilCmd;
process.StartInfo = startInfo;
process.Start();

The variables in the dtutilCmd string are all strings. The issue is when my users input the package name they can get the case wrong. They might write MYPACKAGE so it gets deployed as MYPACKAGE, even if it actually exists as MyPackage on the source server, which I want to preserve.

So I want to somehow grab the package name, and feed it into the last part of my dtutilCmd string.

jarlh
  • 42,561
  • 8
  • 45
  • 63
coinbird
  • 1,202
  • 4
  • 24
  • 44

2 Answers2

1

All you need to do is make use of 'Application' class of Microsoft.Dts.Runtime namespace. You then establish a connection using that and get the packages info from the MSDB.

Here is link that gives more details on how to go about doing it programatically - Enumerating Available Packages Programmatically

VKarthik
  • 1,379
  • 2
  • 15
  • 30
  • Got this to work. For people in the future, the code there will not work outright, it needs quite a bit of tweaking, but the solution is legitimate. – coinbird Sep 08 '17 at 16:30
0

Extract your Integration Service Catalog to ispac. Open it with SSDT, and deploy to your new server. Much easier.

SqlKindaGuy
  • 3,501
  • 2
  • 12
  • 29
  • Why do i get a minus for this? there is no point of copying ssis packages between servers using DTUTIL... – SqlKindaGuy Sep 07 '17 at 06:58
  • I didn't downvote you, but I also don't know what your solution means. Copying packages between servers with DTUTIL is the only way I know how to do it through a C# program. My program does a lot of stuff, so deploying an SSIS package absolutely needs to be done 100% within the C# program. No opening SSMS or anything on the side. – coinbird Sep 07 '17 at 15:47