How do I use a different database connection for package configuration? - sql-server

I have an SSIS Package that sets some variable data from a SQL Server Package Configuration Table. (Selecting the "Specify configuration setings directly" option)
This works well when I'm using the Database connection that I specified when developing the package. However when I run it on a server (64 bit) in the testing environment (either as an Agent job or running the package directly) and I Specify the new connection string in the Connection managers, the package still reads the settings from the DB server that I specified in development.
All the other Connections take up the correct connection strings, it only seems to be the Package Configuration that reads from the wrong place.
Any ideas or am I doing something really wrong?

The only way I was able to do this was to use Windows Environment Variables. You can specify things like connection strings and user preferences in environment variables, and then pick up those environment variables from your SSIS Task.

I prefer to use Server Aliases in the SQL Client Configuration. That way, when you decide to point the package to another SQL Server it is as simple as editing the alias to point to the new server, no editing necessary in the SSIS package. When moving the package to a live server, you need to add the aliases, and it works.
This also helps when you have a real painful naming convention for servers, the alias can be a more descriptive name than the actual machine name.

I didn't actually understand your question completely but I store my connection settings in a configuration files usually one for each environment like dev, production etc. The packages read the connection settings from the config files when they are run.

When you're creating a job to call the SSIS package, and you're setting up the step, there is a tabbed area. The default tab is where you set the package name, and the next tab over is where you can set the configuration file. Have a config file for each package, and change for the server (dev, test, prod). The config file can be put directly on the dev, test, and prod servers, and then point to them when setting up that job.

If u are using SQL Server Package Configuration then all the properties of the packages will come from SQL Server table - Please check that

SSIS security the way it stands is terrible. No one will be able to support things when I am out of the office. The job never reads from the configuration file...I give up. It only works when I edit the string in the Data sources tab. However the password gets lost if you happen to go into the job a second time. Terrible design, absolutely horrible. You would think that when you specify a xml file in the job step it would read the connection string from there that is defined, but it does not. Does this really work for anyone else?

Goto the package properties and set deployment True. This should work for what you have done.

I had the identical question, and got the same answer, i.e. you cannot edit the connection string used for package configurations hosted in SQL Server, except if you specify that the SQL Server connection string should be in an environment variable.
This unfortunately does not work in my dev setup, where two environments are hosted on the same machine. I ended up following Scott Coleman's approach as detailed on SQL Server Central [Free sign-up and a good site]. The trick is that you create a view to store your configuration settings on one central server, and then use the machine that connects to it to determine which environment is active.
I used that approach, but also used the User connecting to the environment to make a determination, because my test and dev setups run on the same SSIS instance, but as different user names. Scott suggests in the comments that the application name should be set, but this cannot be changed in the package execution job step, so it was not an option.
One other caveat that I found was that I had to add "Instead of" triggers to my view to do the inserts, updates and deletes for configuration variables.

We want to keep our package configs in a database table, we know it gets backuped with our other data and we know where to find it. Just a preference.
I have found that to get this to work I can use an environment variable configuration to set the connection string of the connection manager that I am reading my package config from. (Although I had to restart the SQL Server agent before it could find the new environment variable. Not ideal when I deploy this to Production)
Looks Like when you run an SSIS package as a step in a scheduled task it works in this order:
Load each of the Package Configs in the order they appear in the Package Configuations Organiser
Set the Connection Strings from the Data sources tab in the Job Step properties of the Scheduled Job
Start running package.
I would have expected the first 2 to be the other way around so that I can set the data source for my package config from the scheduled job. That is where I would expect other people to look for it when maintaining the package.

Related

Which version of my parameterized SSIS connection string will be used when deploying the project?

I'm creating an SSIS package in which I want to use the Configuration Manager to switch between my development and production server when loading data. I will only need to do this during development (when I'm changing table designs and such).
I've got the project working, and it's using a variable I put in Project.params to change the server appropriately when I choose "Development" or "Production" from the Visual Studio dropdown. (I did this by parameterizing the connection manager.)
My question is: how does SSIS know which mode to use when I deploy the project? I have read that these Configuration choices only apply to running manually in Visual Studio, which is fine, but then which connection string will it use?
The short answer is: it doesn't. At least, it doesn't know how. So, you have to set it.
Set the connection string in as a package Parameter and then map that parameter to an environment variable on the SSIS Server. The environment variable should point to the correct instance in each environment that you promote through. This means that there will be environment variables for each server instance.
I found another answer. I like J. Weezy's answer better because it doesn't involve hard-coding a value in a single place, but I wanted to include this also because it's a possibility for quick testing.
Without taking additional steps the package will not have values set for any parameterized items configured as noted in the question.
What you can do to set default values for these items is go to your project under Integration Services Catalogs, right click the project, select "Configure...", and enter what you want the default value(s) to be for any project parameters on the Parameters tab, like so:
SSIS Project Configuration Screen
(In my example, the parameter value I'm setting is ServerName on a ConnectionManager.)
I found this answer on the following page:
Integration Services (SSIS) Package and Project Parameters

SSIS package executed in Server agent doesn't do its work (even while reporting success)

I have to say that I hate myself for such general question as "What I am doing wrong?" but I simply have no idea what can be the problem:
I've created SSIS package that takes the data from flat files (CSV), counts the average on one of the columns, groups by date and writes it to the database and deletes the original file. All works fine when executed within SSIS, but when I am scheduling it within Server Agent it simply doesn't work - log reports success but there is no new data in the database and the .csv file exists in its original location.
I know the problem with protection level set up in SSIS, so I've changed it to "EncryptAllWithPassword" and I use the same password with Server Agent.
Here is a link to the Server Agent Job script (created as "script job as DROP and CREATE")
Edit: Just to make things weirder, using
dtexcec /f {filepath} /de {password}
executes program without problem. I know I can shedule such command in the Windows itself, but i'd like to keep all scheduled jobs in one place - in the Server Agent
EDIT: Solved by changing the path to UNC
There are two important things to remember when setting up packages to run via a SQL Server Agent job.
Use UNC paths for all file locations, no matter how simple. There is a high probability that the server will have a different view of the file structure than your development machine, so UNC paths ensure that both machines are referencing the same paths.
Use a proxy account to execute that package, as described here http://www.mssqltips.com/sqlservertip/2163/running-a-ssis-package-from-sql-server-agent-using-a-proxy-account/.
The proxy account must have access to the physical paths and the server objects.
This also allows for security stratification on your various packages (not all packages need access to everything).

SSIS Package: Need to update the server name and database name

I have 100 SSIS package all the packages are created in Development environment.
I need to update the server name and database name of all the packages.
It consumes lot of time updating the server name and database name manually.
Is there a way i can update the database and server name in all the packages?
All the packages are stored at same location.
Ideally, you could have a single Master package calling each of your 100 packages which I assume are performing specific tasks. In this Master package, you can pass the Connection Manager details to each 'Child' package during run time itself. The way this is done is by creating variables in each package to hold the server name and database name, and then to update the ConnectionString property in each child package at the start of execution. That way, you only need to generate 1 configuration file for the Master package, and you can configure the database connection parameters as you want. However, this will entail extra development effort as follows:
A new SSIS package to act at Framework level and co-ordinate running the 100 packages
Variables in the new and existing packages to hold server name and database name
A new configuration file in the Master package
The alternative is to just generate configuration files for each of the 100 packages. Then, you will have a separate file for each package, but you will need to make your replacements in each of the configuration files.
You can check out the below links for resources on this:
Configuration Files in SSIS
Variables in SSIS
Have you looked into the "convert to project connection"? If you havent done this yet you are in for a bit of a grind to set it up the first time, but after that you can set your connection for the entire project in 1 place, and configure them in 1 go as well. Just right click on the connection and select the "convert to project connection" for the first connection. Then this project connection becomes visibile for all other components in the project and you can set it up.
Further, if you feel brave and smart you can try to find/replace these settings in the xml code of the packages. This is not easy and not a good idea if you dont know what your doing. If you do know what its all about you can complete this job in 10 minutes flat ;)
Dont say I didnt warn you!
Use update scripts to update internal.object_parameters table
update [SSISDBName].[internal].[object_parameters]
set design_default_value = ‘NewServername’
where design_default_value in (‘OldServerName1′,’OldServerName2’)
update [SSISDBName].[internal].[object_parameters]
set default_value = ‘NewServername’
where default_value in (‘OldServerName1′,’OldServerName2’)
Please find more details on https://moredvikas.wordpress.com/2016/11/17/script-to-update-server-name-in-ssis-package/

Is there a way to easily change the server name on several SSIS packages programmatically?

We are creating several SSIS packages to migrate a large database as part of a release cycle.
We may end up with about 5-10 SSIS packages.
As we have 4 environments (dev, QA, staging, production, etc.), is there an efficient way to change the destination server for each SSIS package as they go through the different server environments? Ideally, there could be a script that is run that would take as a parameter the server that was needed.
You could use a configuration file to store the connection strings for the servers. Then as you moved from environment to environment, you would simply change the config file. To simply create a config file, on the control surface of your package,
1) right click and choose Package Configurations from the context menu.
2) Check the box for Enable package configurations if it is not already selected,
3) then Click the Add... button.
4) Click next on the dialog,
5) then add a Configuration file name: and click next.
6) In the Objects View, Under Connection Managers, expand your connection, then expand Properties and check the box next to ConnectionString.
7) Then click next
8) then finish.
You now have an xml file named what you named it in step 5 above. You can edit this file with a text editor and change the connection string to map to whichever server you need it to before each run.
Once created you can share the config file between multiple packages as long as the objects referenced are named the same between the packages.
This is a rudimentary tutorial on configurations, there are many ways of saving configurations of which this is only one. For more information on configurations consult your favorite SSIS book
We use a config table that stores the configurations for the server. But config files work well too. We like the table because we are doing reporting on SSIS package meta data and it's easier to grab this data (along with a lot of other data we store as well) when stored in a table.
William Todd Salzman's answer covers most points. I have a couple more to add:
Make sure the pacakge ProtectionLevel property is DontSaveSensitive
If you are working with different shipping environments, then a SQL Server table as a source for the package configurations is maybe not for you, as you will require one central database containing all the connection strings for all the servers.
Having worked with package configurations retrieved from the registry, you will need to be aware that these settings are retrieved from the HKEY_CURRENT_USER hive. This has implications for when the package is run through a SQL Agent Job.

How to transfer a ssis package from Dev to Prod?

I'm trying to move my packages to production using a configuration file, but file is changed only partly and the results go still to DEV server.
Does anybody know what to do?
It is difficult to isolate the cause of your issues without access to your configuration files.
What I suggest you do is make use of package configurations that reference a database within your environment. The databases themselves can then be referenced using environment variables that are unique to each environment.
This a brilliant time saver and a good way to centrally manage the configuration of all your SSIS packages. Take a look at the following reference for details.
http://www.mssqltips.com/tip.asp?tip=1405
Once configured, you can deploy the same identical package between dev and production without needing to apply a single modification to the SSIS package or mess around with configuration files.
You could still have hard-coded connections in your package even though you are using a configuration file. You'll need to check every connection as well.
You can also go the long way around. Go into Integration Services and Export the stored package to its dtsx file. Then you can pull open the file in any good text editor, do a find/replace on your server name and then go back into Integration Services and Import the updated package. Alot of times it's just easier...
everybody and thanks for answering. I'd managed to solve this problem in an ugly way - editing packages on server, but I'd like very much more elegant solution - now I'm trying with environment variable,it seems great, but the wizard that I'm getting is different from that is given in link - and I don't know how to continue.(I'm using VStudio 2005) Besides, I tried configuration file as XML, but package run fails even on the source machine, so I'm stuck !
My personal technique has been to first have a single config file that points the package to a SQL Based Package Config (the connection string to the config DB). Subsequent entries in the package config use the SQL store to load their settings. I have a script that goes into the XML of the package and preps them for deployment to stage or prod. A config file holds the name of the Package Configuration's initial file config entry and where the stage and prod configuration db configruation file is located. The script produces two subdirectories for stage and prod. Each directory has a copy of the solution packages modified for their particular deployment.
Also! Don't forget to turn off encryption in the package files!

Resources