Batch File Script to split a string into multiple subsisting in SSIS Execute Process Task

82 Views Asked by At

I was trying to execute a batch file using SSIS execute process task. This task accepts only one argument. The argument is @[User::TabProjectName]=www.servername Dev_Admin Password123 DENMARK DEV V_Weekly_DEV.This is a space-separated string. How to split this single string into multiple substrings based on space and assigned to variables as shown below using Batch command?

set servername=www.servername
set username=Dev_Admin
set tabpwd=Password123
set sitename=DENMARK
set projectname=DEV
set datasourcename=V_Weekly_DEV
1

There are 1 best solutions below

2
Shamus Berube On

This was originally posted with a powershell tag, so this is how it can be done with powershell:

$string = '@[User::TabProjectName]=www.servername Dev_Admin Password123 DENMARK DEV V_Weekly_DEV'

$splitString = $string.split()

$serverName = $splitString[0].split('=')[1]
$username = $splitString[1]
$tabPwd = $splitString[2]
$siteName = $splitString[3]
$projectname = $splitString[4]
$datasourceName = $splitString[5]

$splitString, splits the initial string on spaces as no character is passed to the split operator. Each item in the split array can be referenced by its place number. The $serverName needs an additional split to get the data to the right of the '=' sign.